I want to do the following:
I want to make a very simple gallery application. So I'd like to select a path for the images and set it as a resource. I set it in String.xml.
So I 开发者_JAVA技巧have another class, which needs the selected path to load all the images from it.
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)
but you'll need a Context
Object though.
It's a Function of Context
, so within an Activity you can write this.getString(R.string.image_dir);
or you can skip this
altogether...
精彩评论