异常尝试调用虚拟方法 - WebView Android
Exception attempt to invoke virtual method - WebView Android
我在 Android
中遇到网络视图问题
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
btn = (Button)findViewById(R.id.btnEn);
wv = (WebView) findViewById(R.id.mywv);
//webView.getSettings().setJavaScriptEnabled(true);
//webView.loadUrl("https://mobile.twitter.com/SelbyHigh");
------<Error occuring here under this line>------
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setSupportZoom(true);
wv.getSettings().setBuiltInZoomControls(true);
wv.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
String content = "https://mobile.twitter.com/SelbyHigh";
wv.loadDataWithBaseURL(null, content, "text/html", "utf-8", null);
wv.loadUrl(content);
btn.setOnClickListener(this);
}
这是异常的快照。当我调用它时,我的 activity 没有运行。
[图片Link]http://s13.postimg.org/pjlwlsnuv/errorpng.png
据我所知,当它试图到达 getsettings() 函数时,错误发生在某处。如果您有答案,请在Post 下。如果您希望我提供更多详细信息,请对此问题发表评论。谢谢。
您的网络视图对象为空。请检查布局 xml 以获取 webview id!
您的网络视图为空,因为您尚未调用 setContentView()
。
在进行任何 findViewById()
调用之前先调用 setContentView()
。
我在 Android
中遇到网络视图问题protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
btn = (Button)findViewById(R.id.btnEn);
wv = (WebView) findViewById(R.id.mywv);
//webView.getSettings().setJavaScriptEnabled(true);
//webView.loadUrl("https://mobile.twitter.com/SelbyHigh");
------<Error occuring here under this line>------
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setSupportZoom(true);
wv.getSettings().setBuiltInZoomControls(true);
wv.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
String content = "https://mobile.twitter.com/SelbyHigh";
wv.loadDataWithBaseURL(null, content, "text/html", "utf-8", null);
wv.loadUrl(content);
btn.setOnClickListener(this);
}
这是异常的快照。当我调用它时,我的 activity 没有运行。 [图片Link]http://s13.postimg.org/pjlwlsnuv/errorpng.png 据我所知,当它试图到达 getsettings() 函数时,错误发生在某处。如果您有答案,请在Post 下。如果您希望我提供更多详细信息,请对此问题发表评论。谢谢。
您的网络视图对象为空。请检查布局 xml 以获取 webview id!
您的网络视图为空,因为您尚未调用 setContentView()
。
在进行任何 findViewById()
调用之前先调用 setContentView()
。