Load the images asynchronously in a separate background thread... Thanks, Justin Anderson MagouyaWare Developer http://sites.google.com/site/magouyaware
On Tue, Oct 18, 2011 at 5:27 AM, Sharief Shaik <[email protected]> wrote: > Hi All, > > I have a ListView with dynamic content from web. It has images of size > 480X480 px in each row. These images are downloaded in a separate > thread and stored to SD card and read from there to display in > ListView. The images from SD card are also read using a different > thread. The problem is the ListView scroll is very laggy. What should > we do to fix this problem? > > This is the code that I have written in getView > > final ViewHolder holder; > > try{ > if (convertView == null) { > final LayoutInflater inflator = (LayoutInflater) > context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); > convertView = inflator.inflate(R.layout.my_row, null); > // initilize the UI > > convertView.setTag(holder); > } else { > holder = (MyViewHolder) convertView.getTag(); > > } > > > holder.imageView.setTag(position); > holder.imageView.setImageDrawable(holder.drawable); > > new Thread(new Runnable() { > > @Override > public void run() { > //fetch bitmap from sdcard and set to the imageview > // calling the handler to update the imageView > (holder.imageView.setImageBitmap(bitmap);) > } > }finally{ > bitmap = null; > > } > } > }).start; > > > > return convertView; > } > finally{ > //bitmap = null; > > } > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

