Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this code by Ahmed Zouhir
- //support me by like π and subscribe π½οΈ to my channel
- //i really work hard to provide you this peace of code
- //Create Number Variable y1, y2, x1, x2
- linear1.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View p1, MotionEvent p2){
- switch(p2.getAction()) {
- case MotionEvent.ACTION_DOWN:
- y1 = p2.getY();
- x1 = p2.getX();
- break;
- case MotionEvent.ACTION_UP:
- y2 = p2.getY();
- x2 = p2.getX();
- if (((y1 - y2) < -250)) {
- showMessage("Down");
- }
- if (((y2 - y1) < -250)) {
- showMessage("Up");
- }
- if (((x1 - x2) < -250)) {
- showMessage("Right");
- }
- if (((x2 - x1) < -250)) {
- showMessage("Left");
- }
- break;
- }
- return true;
- }});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement