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;
}
You have to make use of LazyLaoding concept. Here you are trying to download the images on the go which is what is making your listview laggy.
Here is the link,
Lazy load of images in ListView
You will be able to find a huge discussion about lazy laoding and as of which you can see this answer, the most famous concept.
https://stackoverflow.com/a/3068012/603744
EDIT 1
You can also look at endless Adapter for this. Here is a sample,
Android Endless List
https://github.com/commonsguy/cwac-endless
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With