Hope you are fine, in fact it is my first post, I have discovered a lot of things, and a great my Problem solved, but unfortunately the answer to my problem was not found.
The problem is: I am developing an Android application using html, css and javascript. My application depends on the PhoneGap framework. This application has a lot of local pages. In the application, I am trying to handle swipe gesture on Android mobile and move pages based on swipe direction. If the user swipe to the left then the application must call the previous page, if the user swipe right, the application will send the user to the next page.
I can do this by using native Java for Android. But the problem, while calling for the page, I'm impacting a slide for the requested page. But what happens is not the effect of the current page slide, the requested page, which occurs after the slide effect is over, the requested page appears: (I am looking for a mechanism to create an effect that is going to the current local page I did try to delay the animation period but it became very slow, so it became boring and BTW failed to achieve it.
I hope that you will help me in this problem, or suggest any approach or mechanism to me to achieve that effect.
This is my code: / p>
app's public square is DroidGap extended is made before {/ ** called when the activity. * / private static final full SWIPE_MIN_DISTANCE private static final Int SWIPE_MAX_OFF_PATH = 250; private static final full SWIPE_THRESHOLD_VELOCITY = 200; Private gesture detector ischetre Detect Master; see. On the Touch Listnr gesture saved Listnr; @ Otraid public waste created (bundled Instansstet) {super. Contet (saved Instens State); Set contentview (r layout .man); Hint Tector = new gesture detector (new migrate detector); Warning Listener = View New On Touch Listener () {Public Boolean On-Touch (see V, Motion Event Event) {If (detective detector. Touch event) () is true; } return false; }}; Super.loadUrl ("File: ///android_asset/www/index.html"); } Class MyGestureDetector extends SimpleOnGestureListener {@Override public boolean onFling (MotionEvent E1, MotionEvent e2, boat velocityX, velocityY float) {try {if (Math.abs (e1.getY () - GT e2.getY ()) and; SWIPE_MAX_OFF_PATH) Return false; Left hard right // if the injury (e1.getX () - e2.getX () & gt; SWIPE_MIN_DISTANCE & amp; & amp; Math.abs (velocityX) & gt; SWIPE_THRESHOLD_VELOCITY) {appView.startAnimation (AnimationUtils .loadAnimation (getApplicationContext (), r.anim.slide_left)); AppView.goBack (); } Else if (A2kgets () - Alkgets () & gt; Swaip_mn_distens & amp; & amp; Math.abis (Velositiks) & gt; Swaip_threshold_velositi) {Appvievkstartanimsn (Animsnutilsklodnimsn (Getapplictioncontest (), and .anim.slide_right_in)); AppView.goForward (); }} Hold (exception e) {// nothing} return false; }} @ Override Public Boolean Dispatch Touch Event (Motion Adventure E) {SuperDispatch Touch Avent (E); Return gesture detector Tone TouchAvent (E); }} Thanks in advance, Anas Jaghoub
Before adding animation, back () and goForward () are causing incompatible. I suggest you create a custom webview and override the two methods. To some extent, shown below.
Public class expands mywebView webview {public mywebView (reference reference) {super (reference); } @ Override Public Wide GoAback () {} @ Override Public Wide Goferword () {}} Do not miss the keyword @override . Now within these override methods you can add the code for animation. Hope it helps.
Comments
Post a Comment