Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何获取更改字符串";R.drawable.someimage“;要身份证吗?_Java_Android - Fatal编程技术网

Java 如何获取更改字符串";R.drawable.someimage“;要身份证吗?

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

但它不需要字符串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 resource name.