我的onPageFinished
没有解雇。在@OverRide警告“Method does not overwrite the Method in the superclass
”。
我已粘贴相关代码。帮助将深受赞赏。
public class MainActivity extends Activity {
private WebView mWebView;
private String typeOrientation = "landscape";
@Override
protected void onCreate(Bundle savedInstanceState) {
if (typeOrientation.equals("landscape"))
{ setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.activity_main_webview);
/* mWebView.setWebViewClient(new WebViewClient());*/
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
void onPageFinished(WebView view, String url) {
Toast.makeText(getApplicationContext(), "Logout", Toast.LENGTH_LONG).show();
//hide loading image
findViewById(R.id.imageLoading1).setVisibility(View.GONE);
//show webview
findViewById(R.id.activity_main_webview).setVisibility(View.VISIBLE);
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mWebView.setWebContentsDebuggingEnabled(true);
}
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(this, "Android");
mWebView.loadUrl("file:///android_asset/index.html");
}
答案 0 :(得分:1)
你使用了错误的方法。更改为setWebViewClient()
:
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {}
});
答案 1 :(得分:1)
onPageFinished
不属于WebChromeClient
,因此您无法覆盖它。它属于WebViewClient
。您可以设置一个调用setWebViewClient
的实例。您可以阅读更多here。请注意正确的签名是
@Override
public void onPageFinished(WebView view, String url) {
以public
作为访问说明符。