To obtain the image routes, according to your structure you have an object and another one that contains an array called images
, for this you must access the Array and to store the image url you can create an arraylist:
String contenidoJson = "{ 'code':'OK', 'data':{ 'folio':12345, 'customer':'Jose Trinidad Ramos Trejo', 'delivered':'2016/10/30', 'images':[ 'http://kuixx.com/wp-content/uploads/2015/01/Paisajes-5.jpg','http://www.paisajesbonitos.org/wp-content/uploads/2015/12/paisajes-bonitos-de-primavera-verde-lago-agua-natural-animales.jpg','https://wallpapershqpacks.files.wordpress.com/2013/04/049.jpg' ] } }";
//crea lista para almacenar imagenes.
List<String> listaImagenes = new ArrayList<String>();
try {
JSONObject mainObject = new JSONObject(contenidoJson);
JSONObject objectData = mainObject.getJSONObject("data");
JSONArray imagenes = objectData.getJSONArray("images");
for (int i=0; i < imagenes.length(); i++) {
//Agrega imagenes.
listaImagenes.add(imagenes.get(i).toString());
}
} catch (JSONException e) {
e.printStackTrace();
}
Having your list of images you can get the bitmap from the url by using this method :
public static Bitmap getBitmapFromURL(String src) {
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
} catch (IOException e) {
// Log exception
return null;
}
}
by getting the bitmap
you can add it in ImageView
without problem.