0

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!

2 Answers 2

1

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. :)

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.