No video

Change Activity By Right or Left Swipe Android Studio With Source Code.

  Рет қаралды 22,736

Alan Ranjoni

Alan Ranjoni

Күн бұрын

This Tutorial was improved to show a better demo of this simple code from the last tutorial and include a right swipe as well:
Steps:
Create your app as usual, then go to your MainActivity.java.
Declare variables x1, x2, y1, and y2.
Put the following onTouchEvent code right after your onCreate code block closing bracket.
public boolean onTouchEvent(MotionEvent touchEvent){
switch(touchEvent.getAction()){
case MotionEvent.ACTION_DOWN:
x1 = touchEvent.getX();
y1 = touchEvent.getY();
break;
case MotionEvent.ACTION_UP:
x2 = touchEvent.getX();
y2 = touchEvent.getY();
if(x1 less than x2){
Intent i = new Intent(MainActivity.this, SwipeLeft.class);
startActivity(i);
}else if(x1 greater than x2){
Intent i = new Intent(MainActivity.this, SwipeRight.class);
startActivity(i);
}
break;
}
return false;
}
Then add SwipeLeft and SwipeRight empty activities and make your own changes.
-----------------------------------------
||| You are Done! |||
-----------------------------------------
Good Luck
For a slow video with more explanation, check out this one
• Swipe Between Activiti...

Пікірлер: 17
Android Studio Animation: Button Scale and Bounce Animation
9:41
Alan Ranjoni
Рет қаралды 10 М.
We Built an App in 24 Hours [No Code]
11:56
Raw Startup
Рет қаралды 426 М.
The FASTEST way to PASS SNACKS! #shorts #mingweirocks
00:36
mingweirocks
Рет қаралды 12 МЛН
女孩妒忌小丑女? #小丑#shorts
00:34
好人小丑
Рет қаралды 97 МЛН
Ranking Women By Attractiveness | 5 Guys vs 5 Girls
8:07
Jubilee
Рет қаралды 8 МЛН
How to Support ALL Screen Sizes on Android - Full Guide
19:10
Philipp Lackner
Рет қаралды 113 М.
android studio button onclick new activity. KOTLIN Based
10:40
Koltin Android Tutorial
Рет қаралды 9 М.
Pass Data between Activities using intent | Android Studio | Java
13:19
Support Multiple Screen Sizes - Android Studio Tutorial
8:20
Stevdza-San
Рет қаралды 98 М.
How to add sound to a button in android studio | Android studio tutorial
6:04