Java 如何获取更改字符串";R.drawable.someimage“;要身份证吗?
但它不需要字符串id。您可以使用Java 如何获取更改字符串";R.drawable.someimage“;要身份证吗?,java,android,Java,Android,但它不需要字符串id。您可以使用 String path = "R.drawable.pic_" + 4; imageOfPages.setImageResource(path); 从文件中: int id = getResources().getIdentifier("pic_" + 4, "drawable", getPackageName()); if (id > 0) { } Return a resource identifier for the given res
String path = "R.drawable.pic_" + 4;
imageOfPages.setImageResource(path);
从文件中:
int id = getResources().getIdentifier("pic_" + 4, "drawable", getPackageName());
if (id > 0) {
}
Return a resource identifier for the given resource name.