Widget - Motion Detect

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;
}});

//Create Number Variable y1, y2, x1, x2

Komentar

Cara pembuatan Apps paling Populer

TextInputLayout in Sketchware

Create Stopwatch App in Android using Sketchware

How to enable download in webview in Sketchware apps?

Create Stopwatch App in Android using Sketchware

Codes for modifying Action Bar in Sketchware

Code for implementing Notifications in Sketchware

A Flash Light App in Sketchware

How to find and​ highlight a word in a text field in Sketchware?

How to integrate Admob Ads in Sketchware project using AIDE?

Firebase Login/Register with email verification