How to create an Page Control in android
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 d开发者_运维技巧ots....
ViewPager from Compatibility package is currently the best option. http://developer.android.com/reference/android/support/v4/view/ViewPager.html
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)
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
精彩评论