Possible duplicate:
Android - How to make lazy loading of images in ListView
Good afternoon, I made a list with text, image and rating. I get this information using ksoap, which I have already done, and it works like a charm!
Now there is a problem, as I mentioned earlier, I have an image inside the list, if I did not delete the photo, it will become like that laggy/slow response, but after deleting the image it will become smooth again with only text and rating.
How to solve lags if I want to include images. please tell me if you need an example, so I will post android .apk. I hope there is a solution for this. Below is my code for the images in the list:
String s = strTitle[position];
System.out.println(s);
String image_URL = imageURL[position];
BitmapFactory.Options bmOptions;
bmOptions = new BitmapFactory.Options();
bmOptions.inSampleSize = 1;
Bitmap bm = LoadImage(image_URL, bmOptions);
ivLogo.setImageBitmap(bm);
return rowView;
private Bitmap LoadImage(String URL, BitmapFactory.Options options)
{
Bitmap bitmap = null;
InputStream in = null;
try {
in = OpenHttpConnection(URL);
bitmap = BitmapFactory.decodeStream(in, null, options);
in.close();
} catch (IOException e1) { }
return bitmap;
}
private InputStream OpenHttpConnection(String strURL) throws IOException{
InputStream inputStream = null;
URL url = new URL(strURL);
URLConnection conn = url.openConnection();
try{
HttpURLConnection httpConn = (HttpURLConnection)conn;
httpConn.setRequestMethod("GET");
httpConn.connect();
if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK)
{
inputStream = httpConn.getInputStream();
}
}
catch (Exception ex){ }
return inputStream;
}
source
share