有什么办法可以从Android中可绘制文件夹中以String形式获取图像路径。我需要这样做,是因为我实现了自己的viewflow,在其中使用sd卡上的图像路径来显示图像,但是我想在没有图像显示时显示默认图像。
任何想法如何做到这一点?
最佳答案
这些都是方法:
String imageUri = "drawable://" + R.drawable.image;
我测试过的其他方式
Uri path = Uri.parse("android.resource://com.segf4ult.test/" + R.drawable.icon);
Uri otherPath = Uri.parse("android.resource://com.segf4ult.test/drawable/icon");
String path = path.toString();
String path = otherPath .toString();
关于android - Android从可绘制对象获取图像路径为字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8601070/