首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >从字符串值设置android图像?

从字符串值设置android图像?

提问于 2018-01-29 04:48:32
回答 2关注 0查看 165

目前,正在我的Android应用程序中绘制一个PNG图像,如下所示:

代码语言:txt
复制
ImageView image = new ImageView(context);
image.setImageDrawable(context.getResources().getDrawable(R.drawable.testimage))

DB的记录:

代码语言:txt
复制
ID:    Name:    ImageName:
-      Test     testimage

方法之一是:

代码语言:txt
复制
int image = R.drawable.blank; // blank image

// testimage.png is the image name from the database
if(imageName.toString().equals("testimage.png"))
    image = R.drawable.testimage;
else if(imageName.toString().equals("another.png"))
    image = R.drawable.another;
else if(imageName.toString().equals("etc.png"))
    image = R.drawable.etc;

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档