Search code examples
androidandroid-widgettextviewhorizontal-scrollinghorizontalscrollview

Changing a textview by horizontal-scrolling


I want an Android Activity which only function is the next: I show a text (TextView I assume), and where there is an horizontal-scroll I change that text to another one, and so on with about 5 diferent texts.

I would be something like this: text1 <-> text2 <-> text3 <-> text4 <-> text5, where "<->" is a horizontal scroll.

Which are the best Android Widgets to implement this? I have found TextSwitcher and HorizontalScrollView but I'm no sure about what exactly is each one designed for.

Thank you.

PD: those texts aren't changed dinamically, I have an static String for each text (saved in a String[], for example).


Solution

  • You may actually want a ViewPager: http://developer.android.com/reference/android/support/v4/view/ViewPager.html

    From that page: "Layout manager that allows the user to flip left and right through pages of data. You supply an implementation of a PagerAdapter to generate the pages that the view shows." Not sure if this is too complicated for what you're wanting, but it would certainly do the trick.