Created
January 14, 2015 21:40
-
-
Save Coaden/e230be2f1c62161b89d1 to your computer and use it in GitHub Desktop.
Swiping code for Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
View myView = findViewById(R.layout.calender_main); | |
myView.setOnTouchListener(new OnTouchListener() { | |
public boolean onTouch(View v, MotionEvent event) { | |
switch (event.getAction()) | |
{ | |
case MotionEvent.ACTION_DOWN: | |
{ | |
oldTouchValue = event.getX(); | |
break; | |
} | |
case MotionEvent.ACTION_UP: | |
{ | |
float currentX = event.getX(); | |
if (oldTouchValue < currentX) | |
{ | |
// swiped left | |
previousMonth(); | |
} | |
if (oldTouchValue > currentX ) | |
{ | |
//swiped right | |
nextMonth(); | |
} | |
break; | |
} | |
} | |
return true; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment