A.S
A.S

Reputation: 816

Horizontal Paging Android

I am relatively new to android.

I have to design an Activity that has a 2 * 4 grid.

Each grid item will have an image view and a text view

On swiping left or right the user will move to a different page but the UI will remain the same.

Just the data set to the grid will change.

I want the number of pages to be configurable.

Also I want to reuse the same xml file for UI instead of creating two new xml files for the other 2 pages.

Which is the best possible way and the most efficient way to implement this and any examples on how to do this ? Any help will be appreciated. Thank you

enter image description here

Upvotes: 0

Views: 2223

Answers (2)

fweigl
fweigl

Reputation: 22038

You could achieve this with a ViewPager, each page (probably Fragments) containing a RecyclerView with an Adapter..

The fragment code, layout file and adapter implementation would be identical for every page. You just need to pass in the respective data to display to each page.

Upvotes: 1

Tung Duong
Tung Duong

Reputation: 1166

I think you can use ViewPager with Fragment. You can see in this example https://developer.android.com/training/animation/screen-slide.html

Upvotes: 1

Related Questions