2

私の Android アプリケーションには、javascript ファイルをロードする WebView があります。

次に、javascript がいくつかの画像を読み込みます。

//javascript file

var imageObj = new Image();
imageObj.onload = function() {
    // my images is fully loaded
    console.log("image is loaded!");
}
imageObj.src = src;

すべての画像の読み込みが完了したときに webview を表示したいのですが、newProgress == 100 でonProgressChanged が呼び出されるのが早すぎるようです。

//java

@Override
public void onProgressChanged(WebView view, int newProgress) {
    super.onProgressChanged(view, newProgress);

    if (newProgress == 100) {
       mDecorView.addView(view);
       // this is called, but I see the that sometimes the webview didn't finish loading all images.
    }
}

このイベントはいつ呼び出されますか?

これを達成するためのより良い代替手段はありますか?

4

1 に答える 1

0

これを試すことができますか。あなたを助けるかもしれません。

持っているアンドロイドWebviewWebViewClientクラス

public void onPageFinished(WebView view, String url) {

// TODO Auto-generated method stub
super.onPageFinished(view, url);

}

方法。

于 2013-12-15T11:07:50.060 に答える