简体   繁体   中英

Updating GridView with asynctask

I have read in many places that you can't access a gridview from outside the ui thread, but I believe that's what is causing the problem of my gridview taking long to load. I have it with 75 images and it makes the ui hang so it looks like my app is frozen. Is there a way to use async task to load the images into the grid view off the ui thread? or is there a different way to accomplish this?

You should to consider lazy loader for the images.

I suggest you that you change the approach: Display all data except images immediately, then load images with lazy loader. You can even implement image cache if the images are repeated.

That approach will increase speed of your UI and then it doesn't like that app is frozen.

As Bosko mentioned, you need to "lazy" load your images off the main UI thread. I find a great way to take away all the pain of doing this is to use a library like Picasso which makes it dead simple. It handles all of pitfalls you will encounter if you try to create a lazy loader yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM