slider - How to detect android slide/swipe menu event from the left end of screen? -


i don't have slider menu/drawer, make use of slider event, in apps show drawer left side of screen. need different task when user gesture.

is possible listen event? if yes how ?

import android.app.activity; import android.util.log; import android.view.motionevent;  public class slidableactivity extends activity {     protected static final string tag = "slidableactivity";     private static final int action_type_default = 0;     private static final int action_type_up = 1;     private static final int action_type_right = 2;     private static final int action_type_down = 3;     private static final int action_type_left = 4;     private static final int slide_range = 100;     private float mtouchstartpointx;     private float mtouchstartpointy;     private int mactiontype = action_type_default;      @override     public boolean ontouchevent(motionevent event) {         int x = (int) event.getrawx();         int y = (int) event.getrawy();         switch (event.getaction()) {         case motionevent.action_down:             mtouchstartpointx = event.getrawx();             mtouchstartpointy = event.getrawy();             break;         case motionevent.action_move:             if (mtouchstartpointx - x > slide_range) {                 mactiontype = action_type_left;             } else if (x - mtouchstartpointx > slide_range) {                 mactiontype = action_type_right;             } else if (mtouchstartpointy - y > slide_range) {                 mactiontype = action_type_up;             } else if (y - mtouchstartpointy > slide_range) {                 mactiontype = action_type_down;             }             break;         case motionevent.action_up:             if (mactiontype == action_type_up) {                 slideup();             } else if (mactiontype == action_type_right) {                 slidetoright();             } else if (mactiontype == action_type_down) {                 slidedown();             } else if (mactiontype == action_type_left) {                 slidetoleft();             }             break;         default:             break;         }         return true;     }      protected void slidetoleft() {         log.d(tag, "slidetoleft() called.");     }      protected void slidetoright() {         log.d(tag, "slidetoright() called.");     }      protected void slideup() {         log.d(tag, "slideup() called.");     }      protected void slidedown() {         log.d(tag, "slidedown() called.");     } } 

checkout link too


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -