How to add 'next' feature in GridView?

view story

http://stackoverflow.com – I have made a gridview in which i have tried to add next feature in that grid. When someone clicks on "next", the grid is loaded with new bunch of images. I have made a logic and somehow it is working but it is not stable. App gets stopped sometimes and sometime on clicking "next" the next page get skipped (Suppose currently i am on page 0 and when i click on "next" grid gets refreshed and page 2 is shown instead of page 1) What i am doing is I have made a asynctask which send http request to the php server for new urls of images. then i refresh the gridview and display the new images from n (HowTos)