安卓得到绘制的字符串图像路径 [英] Android get image path from drawable as string

查看:177
本文介绍了安卓得到绘制的字符串图像路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法,我可以在Android的绘制,从文件夹中的图像路径​​字符串。我需要这个,因为我实现我自己的viewflow在那里我展示这些图像通过使用SD卡的路径,但我想说明一个默认的图像时没有图像显示。

Is there any way that I can get the image path from drawable folder in android as String. I need this because I implement my own viewflow where I'm showing the images by using their path on sd card, but I want to show a default image when there is no image to show.

任何想法如何做到这一点?

Any ideas how to do that?

推荐答案

这些都是方法:

String imageUri = "drawable://" + R.drawable.image;

我测试过其他方式

Other ways I tested

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();

这篇关于安卓得到绘制的字符串图像路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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