With Android Studio
I have a code that displays images
from a direct URL
.
I want that displays all the images
from a site (they are item called <enclosure/>
) and put that in my Custom ListView
. So I get the String
of the URLs
where is present the image
and then show it by the code below but I get nothing. Can you help me?
TextView txtImage = (TextView)rowView.findViewById(R.id.item_image);
txtImage.setText(web.get(position).getEnclosure());
txtImage.setTypeface(myTypeface);
ImageView img = (ImageView) rowView.findViewById(R.id.enclosure);
try {
URL url = new URL(context.getString(R.id.item_image));
HttpGet httpRequest = null;
httpRequest = new HttpGet(url.toURI());
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient
.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
InputStream input = b_entity.getContent();
Bitmap bitmap = BitmapFactory.decodeStream(input);
img.setImageBitmap(bitmap);
} catch (Exception ex) {
}