📌  相关文章
📜  如何以编程方式将可绘制名称设置为图像视图 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:34.778000             🧑  作者: Mango

代码示例1
String uri = "@drawable/myresource";  // where myresource (without the extension) is the file

int imageResource = getResources().getIdentifier(uri, null, getPackageName());

imageview= (ImageView)findViewById(R.id.imageView);
Drawable res = getResources().getDrawable(imageResource);
imageView.setImageDrawable(res);