Hide WebView until JavaScript is done

后端 未结 2 933
星月不相逢
星月不相逢 2020-12-05 17:03

I have a webview

WebView wv;
wv = (WebView)findViewById(R.id.webView1);
wv.loadUrl(\"http://example.com/\");

Simply said.

at:

2条回答
  •  借酒劲吻你
    2020-12-05 17:17

    I had the same problem of @GromDroid.

    Maybe not the best solution but it works:

    public class myJavaScriptInterface {
            @JavascriptInterface
            public void setVisible(){
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                wb.setVisibility(View.VISIBLE);
                            }
                        }, 500);
                    }
                });
            }
        }
    

    I've added a delay of half second before make the webview visible.

提交回复
热议问题