开发者

WebView: Enforcing Sequenced Display Timing

I need some tutorial-level help with displaying WebView content in a timed sequence.

Below is just a testbed to illustrate, the manifest is a bog-standard WebView in a RelativeLayout.

package com.example;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.widget.RelativeLayout;

public class MyActivity extends Activity
{
    private String imgPath;  // empty for testing
    /** Called when the activity is first created. */
    @Override
   public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final WebView mWebView1;
            mWebView1 = (WebView) findViewById(R.id.webviewCard1);
            mWebView1.setLayoutParams(new RelativeLayout.LayoutParams(300,200));

        String fill = "First Content";
        mWebView1.loadDataWithBaseURL(imgPath, fill, "text/html", "utf-8",null);

        /*
        I want the above to load, display First Content (t开发者_StackOverflow中文版ext, image(s), play any
        sound files) then pause for a preset time before doing the same for the 
        Second Content
        */

        fill = "Second Content";
         mWebView1.loadDataWithBaseURL(imgPath, fill, "text/html", "utf-8",null);
    }
}

So how do I enforce a wait of n seconds between loadDataWithBaseURLs (on the same or different WebViews)?

TIA,

Ken


how about: mWebView1.postDelayed(..., timeout);

or

Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(command, initialDelay, delay, unit);

I think any timer will do, just make sure you call webview methods on UI thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜