0

I have two web urls. I want to display each webpage 10 seconds in webview. I've used for loop for count urls. I want to display second web page in 10 seconds after loading first webpage. How can I set timer for this code.

 for(int i=1;i<=2;i++){

    if(i==1)
    {
        URL_="https://www.google.lk/?gws_rd=ssl";
        }
    else
    {
        URL_="https://www.yahoo.com/";
    }

    slideWebView.loadUrl(URL_);
    WebSettings webSettings = slideWebView.getSettings();
    WebSettings.setJavaScriptEnabled(true);
    slideWebView.getSettings().setLoadWithOverviewMode(true);   
    slideWebView.getSettings().setUseWideViewPort(true);
}
Yasi
  • 23
  • 6

2 Answers2

1

You can use this code

slideWebView.loadUrl("https://www.yahoo.com/");
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
             slideWebView.loadUrl("https://www.google.lk/?gws_rd=ssl");
        }
    }, 10000);
Krishna V
  • 1,801
  • 1
  • 14
  • 16
0

Do the steps below

-take a FrameLayout and inside that put two WebView one on the top of other.

-load your two url in these two webview.

-Set Timer to 0 and when timer goes 10 sec make the below child to forward.

-for Timer you can follow: How to set a timer in android

-for Frame Layout you can follow: http://developer.android.com/reference/android/widget/FrameLayout.html

Hope you will get the concepts..thanks If you still need the code than let me know.

Community
  • 1
  • 1
sahu
  • 1,188
  • 10
  • 19