我已将图像名称(例如“Image1.png”)存储在JSON
文件中。我已经使用JSONParser
. 但问题是我无法在ImageView
.
这是我写的代码:
ImageView imageView = (ImageView)findViewById(R.id.imageViewer);
for (int i = 0; i < posts.length(); i++) {
JSONObject c = posts.getJSONObject(i);
String varImage = c.getString(TAG_IMAGE);
int resId = getResources().getIdentifier(varImage, "drawable" , getPackageName());
imageView.setImageResource(resId);
//code to add data in hash map
}