How to create page control in android

How to create page control in android .... I want to go from one page to another page, for example, to the main screen in an Android device ... it displays the current page from 3 to 4 points ....

+3
source share
3 answers

I managed to do 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 in the ScrollView scroll processing area

And here: Android horizontal scrollview behaves like an iPhone (paging)

0
source

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

+2

You can use ViewFlipper with animation to do this, but for the Touch event you have to create a custom view. http://www.androidpeople.com/android-viewflipper-example

0
source

All Articles