下面我编写了出现错误的函数,即 -
“无法从 WebView 类型对非静态方法 setWebViewClient(WebViewClient) 进行静态引用”。
我得到它的线****
在它的开头。如何纠正这个错误?
public class Webview extends Activity {
WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
//webviewclient
WebViewClient yourWebClient = new WebViewClient()
{
// Override page so it's load on my view only
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
};
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
**** WebView.setWebViewClient(yourWebClient);
webView.loadUrl("http://www.google.com");
}