I want to add an image to my iamgeview using a link stored in a JSON file that looks like this:
{ "parts":[ {"name": "Bosch Iridium", ... ... ... "image": "R.drawable-hdpi.plug_boschi" },
Right now I am pulling the link and showing it with this code:
try { jObject = new JSONObject(sJSON.substring(sJSON.indexOf('{'))); JSONArray pluginfo = jObject.getJSONArray("parts"); JSONObject e = pluginfo.getJSONObject(position); String imagefile = e.getString("image"); Drawable image = getDrawable(imagefile); ImageView itemImage = (ImageView) findViewById(R.id.item_image); itemImage.setImageDrawable(image); } catch (JSONException e) { e.printStackTrace(); } }
I am sure this part is correct.
ImageView itemImage = (ImageView) findViewById(R.id.item_image); itemImage.setImageDrawable(image);
But I need help with the part above that gets the link from the JSON array so that I can display it.
source share