我在Android应用程序中有一个android.widget.ImageView。我怎样才能得到它正在显示的图像的名称?如何检索ImageView显示的图像名称?
0
A
回答
1
这是不可能的。您必须在设置图像名称时保存图像名称,无论是在自定义ImageView
子类中还是在Activity
中。
2
如果从资源利用,那么你可以得到使用getResourceName
String imageName = getResources().getResourceName(R.id.img);
或者你可以得到&设置图像标签和使用它。
imageView.setTag("android.png"); // using java
android:tag="android.png" // using xml
imageView.getTag();
,但如果你是从服务器下载或使用extranl路径在那个时候,你必须拆分像
//Your last index value is your image name
String image_path = "this/is/chintan/khetiya/android.png";
String[] result = image_path.split("/");
for (int x = 0; x < result.length; x++) {
System.out.println(result[x]);
Log.i("value", "" + result[x]);
}
结果图像路径:android.png
和最后Change your image name当您从服务器下载时。
相关问题
- 1. 检索图像的名称
- 2. 如何用imageview查找图像名称?
- 3. 如何检索图像和显示
- 4. 如何在imageView中获取图像的图像名称?
- 5. 如何在ImageView中显示图像?
- 6. 如何在ImageView上显示图像
- 7. 如何在图像视图中显示20个图像名称
- 8. 检索图像 - 不显示图像
- 9. Linux检索显示器名称
- 10. 如何通过图像名称在Xcode显示图像5
- 11. 如何在单击该图像时从ImageView中检索图像?
- 12. 在imageview上显示图像
- 13. imageview不显示图像
- 14. ImageView停止显示图像
- 15. imageView不显示图像xcode9
- 16. ImageView不显示图像
- 17. JavaFX ImageView图像不显示
- 18. 在imageview中显示图像
- 19. ImageView未显示图像
- 20. Android ImageView不显示图像?
- 21. ImageView未显示图像钛
- 22. 检索ImageView中的“Clean”图像
- 23. 当TextField中输入的文本与图像名称匹配时,如何在ImageView中显示图像?
- 24. Android:如何获取ImageView的背景图像的名称
- 25. 如何在iPhone的imageview中显示图像的特定像素
- 26. 如何显示iOS中的UIImage的NSArray的图像名称
- 27. Javascript要显示图像名称列表
- 28. 如何在gridview中显示带有图像名称的图像图标
- 29. 通过JSON在ImageView中检索图像
- 30. ImageView的不显示图像的Android
这是可能的。 –
@chintankhetiya实际上,您提供的解决方案仅仅是我提到的两种可能性的另一种解决方法。我的意思是:没有像getDrawableName()或getImageName()这样的方法。 –
检查我的答案,是的,这是可能的,如果编码网址没有具体的图像名称在那个时候,我们必须保存具体名称,我已经在我的答案中提到。纠正我,如果我错了 –