I am new Android developer. I want to achieve the following: On a particular screen (Activity) I have a grid view with images being set onto it. I have hundreds of thumbnail images coming from a server via http request. Now I don't want the gridview (with 4 columns in one row) to load the images in one go. Instead I want images to be loaded one开发者_StackOverflow row at a time (4 images), with other tiles of the grid view showing progess bar. Also when only few images are displayed the user should still be able to scroll the gridview vertically and thereby displaying empty gridview frames or tiles but if the scrolling is paused the frames or tiles of gridview are again loaded one row at a time. I am looking for ideas to achieve this. Thanks in advance for your responses.
- In your Adapter's
getView
method set the image with a indefinite progress spinner. - After that start an
AsyncTask
to download the image if its not present in the object returned bygetItem
. Pass the item'sposition
to the asynctask. - In
AsyncTask
'sonPostExecute
set the image to the view atposition
and hide the progress spinner.
Downloading the image in AsyncTask
will ensure that your gridview is filled with items(empty) and responds to scrolling.
精彩评论