3

How to create an Page Control in android.... I want to move from one page to another page, like the home screen in android device... it displays the current page by the 3 to 4 dots....

richq
  • 55,548
  • 20
  • 150
  • 144
Saran
  • 167
  • 2
  • 3
  • 11

3 Answers3

2

ViewPager from Compatibility package is currently the best option. http://developer.android.com/reference/android/support/v4/view/ViewPager.html

kzotin
  • 5,365
  • 3
  • 29
  • 36
0

You can use ViewFlipper with animation to do this but for Touch event you have to crate Custom view. http://www.androidpeople.com/android-viewflipper-example

Sujit
  • 10,512
  • 9
  • 40
  • 45
0

I've managed to do exactly the same by doing something like:

int currentScreen = 1;

final GestureDetector gestureDetector = new GestureDetector(
                new MyGestureDetector());

findViewById(R.id.homescreen).setOnTouchListener(
                new View.OnTouchListener() {
                    public boolean onTouch(View v, MotionEvent event) {

                        if (gestureDetector.onTouchEvent(event)) {
                            return true;
                        } else if (event.getAction() == MotionEvent.ACTION_UP
                                || event.getAction() == MotionEvent.ACTION_CANCEL) {
                                ...detect scroll and change var...

As described here: HorizontalScrollView within ScrollView Touch Handling

And here: Android horizontal scrollview behave like iPhone (paging)

Community
  • 1
  • 1
neteinstein
  • 17,529
  • 11
  • 93
  • 123