我想做以下事情:
我想做一个非常简单的画廊应用程序。所以我想选择图像的路径并将其设置为资源。我在 String.xml 中设置它。
所以我有另一个类,它需要选定的路径来加载其中的所有图像。
class ImageHolder
{
public ImageHolder()
{
this(R.string.image_dir);
//problem is here - R.string.image_dir returns a unique int, while what I really need is the string. How can I get it...
}
public ImageHolder(String path)
{
.........standart procedure.....
}
}
Use getString(resID)
但你需要一个Context
尽管反对。
这是一个函数Context
,所以在 Activity 中你可以写this.getString(R.string.image_dir);
或者你可以跳过this
共...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)