3

I'm wondering how could i implement in an app the following behaviour : changing activities within the application using gesture similar to changing screens on the homescreen.

Let's say i'm in activity B and if i do a sweep from left to right ( ---> ) i would get to activity C and if i do it from right to left, i would get the A activity. With the cool animation like when switching screens.

Any ideas ?

Thank you!

maephisto
  • 4,952
  • 11
  • 53
  • 73

4 Answers4

0

This will be hard to implement, but you can try catch touch events in views of your B activity, and start Activities A or C.

Here is good instruction of animation for activities.

Community
  • 1
  • 1
Jin35
  • 8,602
  • 3
  • 32
  • 52
0

for changing the activity you can do one way (note animation not implemented in this) by implementing onTouch() method of activity now track on the down event get the current tap location and in move set the flag for move event if you tap and move then only change. Now in up event get the current location of the tap and compare it.

If the up event location was less then down event location then start activity A if the up event location was more than down event location then start activity C

Pratik
  • 30,639
  • 18
  • 84
  • 159
0

If you want to implement something like in the new Google+ app, you might look at ViewPager and one of the ViewPagerIndicator implementations, for example this one (which I have already used successfully) or this one (which I'm going to check out over the weekend).

This may in some cases be much easier than actually switching between activities, having the same "effect" for the user.

Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
0

Better you port your activity code to fragments.

You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities.

Otherwise you can also use ViewFlipper depending on you requirement

MGK
  • 7,050
  • 6
  • 34
  • 41