I have a json on a server with links of images and need to convert to imageView, I could only open on the android screen as a string showing the image link.
Mycodethatreceivesjson
StringRequestrequest=newStringRequest(url,newResponse.Listener<String>(){@OverridepublicvoidonResponse(Stringstring){parseJsonData(string);}},newResponse.ErrorListener(){@OverridepublicvoidonErrorResponse(VolleyErrorvolleyError){Toast.makeText(getApplicationContext(),"Some error occurred!!", Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
});
RequestQueue rQueue = Volley.newRequestQueue(MainActivity.this);
rQueue.add(request);
}
void parseJsonData(String jsonString) {
try {
JSONObject object = new JSONObject(jsonString);
JSONArray fruitsArray = object.getJSONArray("fruits");
ArrayList al = new ArrayList();
for(int i = 0; i < fruitsArray.length(); ++i) {
al.add(fruitsArray.getString(i));
}
ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1, al);
fruitsList.setAdapter(adapter);
} catch (JSONException e) {
e.printStackTrace();
}
dialog.dismiss();
}