Android的:如何获得绘制的图像的名字如何获得、图像、名字、Android

由网友(梓安)分享简介:我想获得绘制的图像的名称,并希望存储在一个字符串名称。例如,对于图像,我可能会使用.png文件名为play.png或stop.png。我只是想知道哪些图像中绘制用于ImageView的..有什么办法让提拉/(?? PNG)的名称I want to get the name of the drawable image...

我想获得绘制的图像的名称,并希望存储在一个字符串名称。例如,对于图像,我可能会使用.png文件名为play.png或stop.png。我只是想知道哪些图像中绘制用于ImageView的..有什么办法让提拉/(?? PNG)的名称

I want to get the name of the drawable image and want to store that name in a string. For example , for an Image, I might use a .png file named play.png or stop.png. I just want to know which image in drawable is used for the ImageView.. Is there any way to get the name of the drawable/(??.png)

感谢。

推荐答案

我DONOT认为有任何直接的方式,除非你存储图像名称以及图像获取绘制的图像的名称。

I donot think there is any direct way to get name of drawable image unless you stores the image name along with image.

在XML,你可以做以下设置图像名称作为附加数据的ImageView

In XML you can do the following to set image name as an additional data to imageview

android:tag="btful.png"

Programmetically设置imagename

Programmetically setting imagename

ImageView img = (ImageView) findViewByID(R.id.img)// my image
img.settag("btful.png"); // to set an image name

您可以通过使用getTag获得图像的名称()

you can get the image name by using getTag()

String imageName = (String)img.getTag();
阅读全文

相关推荐

最新文章