Swipe detection for Android developers and sketchwere

Hello developers in this generation much more apps have sliding menus. in this type menu just swipe left or right and open your target page…

To create this type menu add simple code to detect swipe and get instruction data from user swipe and throw out result. Please see below the code for swipe detection and perform after detect

linear_id.setOnTouchListener(new View.OnTouchListener() {@Override public boolean onTouch(View p1, MotionEvent p2){ switch(p2.getAction()) { case MotionEvent.ACTION_DOWN: f = p2.getX();break; case MotionEvent.ACTION_UP: t = p2.getX();if (((f - t) < -250)) {_slideLeft();} if (((t - f) < -250)) {_slideRight();}break;}return true;}});

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.