Navaneeth Sen
Navaneeth Sen

Reputation: 6466

How to page a gridviews in android?

I would like to create pages of gridview in android.
The page 1 will have a 3x3 set of elements.
On clicking the next button it should jump to page-2 with the next 3x3 set of elements.

Right now i have a grid of 3x3 elements and when i give a set of 12 elements, a scrollbar will appear in the right side of the gridview and the next three elements will be shown in the same page by scrolling down.

So please help on how i can implement a page of gridviews.

Thanks,
Sen

Upvotes: 2

Views: 1083

Answers (1)

Siebe
Siebe

Reputation: 138

Limit the number of items you pass to the gridview adapter. Assuming that you have an array of items, in your newInstance() method, select from that array 9 elements according to the page. Then pass that array to the gridview adapter. Also, let your getCount method in your gridview adapter return 9.

Sorry I don't give code right now, but if it isn't clear, I will provide done snippets when I have pc access.

Upvotes: 1

Related Questions