如何在java中获取图像名称?

时间:2011-10-26 09:36:10

标签: android imageview

我想在android中获取图片名称

例如,

ImageView img = (ImageView)findViewByID(R.id.MyImage);

img.srcName() // it should return following android:src="@drawable/abc"
是不是可能? 任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:3)

您可以使用此功能获取资源的名称:

getResources().getResourceName(resid);

但你需要resId。 查看Resources.

答案 1 :(得分:1)

  

是否有可能?

这是不可能的。对于初学者来说,ImageView可能没有涉及资源,因为图像可能来自很多地方。

相关问题