【问题标题】:When does onProgressChanged get to 100?onProgressChanged 什么时候达到 100?
【发布时间】:2013-12-15 10:46:55
【问题描述】:

在我的 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,但似乎 onProgressChanged 被称为 为时过早 且 newProgress == 100。

//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.
    }
}

什么时候调用这个事件?

有没有更好的选择来实现这一点?

【问题讨论】:

    标签: javascript android webview webchromeclient


    【解决方案1】:

    你能试试这个吗?可能对你有帮助。

    android Webview WebViewClient 类有

    public void onPageFinished(WebView view, String url) {
    
    // TODO Auto-generated method stub
    super.onPageFinished(view, url);
    

    }

    方法。

    【讨论】:

    • onPageFinished 被称为 before onProgressChanged 100%
    猜你喜欢
    • 2017-02-07
    • 2010-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-28
    • 2012-08-07
    • 2012-04-05
    相关资源
    最近更新 更多