我想做以下事情:
我想制作一个非常简单的图库应用程序.所以我想为图像选择路径并将其设置为资源.我在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.....
}
}
Run Code Online (Sandbox Code Playgroud)
st0*_*0le 21
使用,getString(resID)但你需要一个Context对象.
它是一个函数Context,所以在一个Activity你可以写,this.getString(R.string.image_dir);或者你可以this完全跳过...
| 归档时间: |
|
| 查看次数: |
7970 次 |
| 最近记录: |