开发者

android - get a resource (a string) from its unique integer

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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜