Possible Duplicate:
Android - How do I do a lazy load of images in ListView
Good day, I have done a listview with a text, image and a ratingbar. I get these information by using ksoap
which i already done and it works like charm!
Now there is a problem, as i mentioned earlier, i do have a image inside the listview, if i didn't remove the photo, it will become so laggy/slow response
but after i remove the image, it will become smooth again just only with the textview and ratingbar.
How to solve the laggy if i wanted to include the images. please do tell me if u need a example so i will post the android .apk . I hope there is a solution for this. below my code for the images at listview:
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;
}