【发布时间】:2016-01-27 06:19:25
【问题描述】:
为了简单起见:我从 JSON 文件中获取了可绘制对象的名称,并且现在位于变量中,如何将正确的可绘制对象分配给名称为 String 的 ImageView?我们可以假设同名的drawable总是存在的。
String image_name = "image1.png";
ImageView imageView = (ImageView)view.findViewById(R.id.myImageView);
imageView.setImageResource(image_name); // FAIL since is expecting the drawable and not the name as a String.
【问题讨论】:
标签: java android android-drawable