I'm coding an android application. I have an array containing many url. I have loaded the first url on webview in mainactivity, and i want to load next url when i swipe. I'm using webview to load the url. So now I have to do as to how to load the next url by swipe
Asked
Active
Viewed 710 times
0
-
Set an touch listener to webview and process as u wish on swipe. But there is a problem the web site that u load may need some swipe to see whole data, so it is not good to override the touch of webview. – Viswanath Lekshmanan Jul 07 '14 at 18:27
-
Thanks, so if i don't use webview, what i can to load url and swipe better webview – user1916184 Jul 07 '14 at 18:32
-
Did you tried this , pls look in to this http://stackoverflow.com/questions/21565131/android-left-right-swipe-gesture-in-webview-activity-with-clicking-on-links-and – Viswanath Lekshmanan Jul 07 '14 at 18:36
1 Answers
0
1- Use this library and follow this wiki for easy gesture detect.
2- Get next item of array and load it to WebView.
Example code:
myView.setOnTouchListener(new OnSwipeTouchListener(this) {
@Override
public void onSwipeDown() {
Toast.makeText(MainActivity.this, "Down", Toast.LENGTH_SHORT).show();
}
@Override
public void onSwipeLeft() {
Toast.makeText(MainActivity.this, "Left", Toast.LENGTH_SHORT).show();
}
@Override
public void onSwipeUp() {
Toast.makeText(MainActivity.this, "Up", Toast.LENGTH_SHORT).show();
}
@Override
public void onSwipeRight() {
Iterator<String> it = al.iterator();
while (it.hasNext()) {
yourWebView.loadUrl(it.next());
}
}
});
I don't have eclipse but it must be something like that.

Lazy
- 1,807
- 4
- 29
- 49