如何从可绘制对象获取图像名称? [英] How to get image name from Drawable Object?

查看:70
本文介绍了如何从可绘制对象获取图像名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以某种方式,我从Drawable文件夹中获得了Drawable图像,例如

Somehow I have Drawable image from Drawable folder like as

Drawable thumb = mContext.getResources().getDrawable(R.drawable.image_name);

我这样尝试

String image_name =thumb.getCurrent().toString();

但是我需要的图像名称就是拇指的图像名称;

But my need image name that means image_name from thumb;

这怎么可能?

任何建议,评论,咨询;提供有用的链接受到高度赞赏.预先感谢

Any suggestion, comment, consults; provide useful links are highly appreciate. Advance Thanks

推荐答案

您可以尝试以下操作:

int imageid = getResources().getIdentifier("image_name", "drawable", getPackageName());
String imageName = getResources().getResourceName(imageid);

这篇关于如何从可绘制对象获取图像名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆