开发者

complex listeviewitem image load hang application problem

开发者 https://www.devze.com 2022-12-14 10:39 出处:网络
I am suing Listview and customize listview to display image inside a list item. I want display image with every search result.

I am suing Listview and customize listview to display image inside a list item. I want display image with every search result.

to display complext listeim i am following the following example

http://developer.android.com/guide/samples/ApiDemos/sr开发者_开发知识库c/com/example/android/apis/view/List4.html

inside wrapper class i am initiating new thread for every new list item's image so that i won't dealy the displaying image.

my code is below

new Handler().post(new Runnable(){
                   @Override 
                   public void run() {
                Drawable dImage = Util.getImageFromURL(imageURL); 
                getImageIcon().setImageDrawable(dImage);

                }
});

mean 10 images initiates 10 different image loading threads other static data is not inside thread.

problem arises when during image loading page application getting hang it should not hang.... any idea what to do ?

alt text http://img509.imageshack.us/img509/7519/thumbnailx.jpg


Use a background operation to retrieve your images, such as an AsyncTask. All your new Handler().post() stuff does is delay the work by a nanosecond, not have it be performed in the background.

Also, if you are going to use Handlers, just create one.

0

精彩评论

暂无评论...
验证码 换一张
取 消