deepak kumar
deepak kumar

Reputation: 70

Swipe for activities in Android

I am trying to build an app in which I want to go to a new page through swipe-say. I have about 10 different pages and I want to go to these pages by swiping. Can I implement these pages as separate activities? Can I swipe from one activity to another? I strongly like to implement these pages in seperate xml files rather than creating everything in a single xml page. But as far as I have searched, there are no proper tutorials or blogs giving an appropriate example of a program implementing swipe. If possible, provide some working codes. Thanks in advance.

Upvotes: 0

Views: 1350

Answers (3)

R.daneel.olivaw
R.daneel.olivaw

Reputation: 2679

Please try the attached link View flow.

I feel it will fit your needs perfectly. You can even create different xmls and inflate them into different view objects and then use the "view flow" to switch between them.

Demo image 1 Demo image 2

The "view flow" is perfect for handling both simple & complicated views. The flow indicator on the top of the screen is optional.

I hope it helps..

Upvotes: 0

Ramseys
Ramseys

Reputation: 431

In Android, swipe is not identified as a particular gesture. You can use a OnTouchListener registered on your view, and animate your view if the gesture exeeds a certain threshold. You can then launch a new activity, or in a simpler way, use a viewFlipper.

Upvotes: 0

Jave
Jave

Reputation: 31846

It seems that a FragmentPager is what you want. Examples and code on the linked page.
If you build for earlier versions of Android, the necessary code is included in the Android Support Package.

Upvotes: 1

Related Questions