Advertisement
Ahmed_Zouhir

motion /gesture detect sketchware

Jan 3rd, 2019
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. //this code by Ahmed Zouhir
  2. //support me by like πŸ‘ and subscribe πŸ“½οΈ to my channel
  3. //i really work hard to provide you this peace of code
  4. //Create Number Variable y1, y2, x1, x2
  5.  
  6. linear1.setOnTouchListener(new View.OnTouchListener() {
  7. @Override
  8. public boolean onTouch(View p1, MotionEvent p2){
  9. switch(p2.getAction()) {
  10. case MotionEvent.ACTION_DOWN:
  11. y1 = p2.getY();
  12. x1 = p2.getX();
  13. break;
  14. case MotionEvent.ACTION_UP:
  15. y2 = p2.getY();
  16. x2 = p2.getX();
  17. if (((y1 - y2) < -250)) {
  18. showMessage("Down");
  19. }
  20. if (((y2 - y1) < -250)) {
  21. showMessage("Up");
  22. }
  23. if (((x1 - x2) < -250)) {
  24. showMessage("Right");
  25. }
  26. if (((x2 - x1) < -250)) {
  27. showMessage("Left");
  28. }
  29. break;
  30. }
  31. return true;
  32. }});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement