I have a task like this:
Assume I have a list of 28 items.
I want to display 5 items at a time in the screen horizontally.
When user touch and drag to the left, it will be update by the next 5 items.
When user touch and drag to the right it will be update by the previous 5 items.
I don't know how to do it.
I need help, please!
Add a comment
|
2 Answers
Solution 1:
A combination of HorizontalScrollView and LinearLayout with horizontal orientation should work for you.
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:scrollbars="none" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="horizontal" >
<!-- your items here -->
</LinearLayout>
</HorizontalScrollView>
Solution 2:
If you are certain that you want the whole batch of items to get replaced, then you should go for ViewPager.
Hope this helps. :)
I've not used this myself but try https://github.com/MeetMe/Android-HorizontalListView
Unlike HorizontalScrollView this works with ListAdapters just like the traditional vertical ListView does.