我在json文件中储存了图像名,例如:"Image1.png"。我使 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
}