开发者

How to display bunch of images without giving the local resource names in the code?

开发者 https://www.devze.com 2023-01-26 15:51 出处:网络
Hi I am working on a application where I need to display bunch of images for some conditions. Is th开发者_如何学Pythonere any simpler way to get all images without mentioning the resource names as in

Hi I am working on a application where I need to display bunch of images for some conditions. Is th开发者_如何学Pythonere any simpler way to get all images without mentioning the resource names as in Android platform like

 int id = getResources().getIdentifier(imgName, "drawable",
            getPackageName());

Please anybody help me in this regard.Thanks in advance.


I think you don't want to hard code image names. So you can use ResourceBundle.

static ResourceBundle _resources=ResourceBundle.getBundle(MyAppResourcesResource.BUNDLE_ID, MyAppResourcesResource.BUNDLE_NAME);

Bitmap bitmap = Bitmap.getBitmapResource(_resources.getString(MyAppResourcesResource.IMAGE_NAME));

For details of ResourceBundle read this article.

Localizing an application

0

精彩评论

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

关注公众号