【发布时间】:2015-05-28 01:11:45
【问题描述】:
我在 Android 中遇到了 webview 问题
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);
}
这里是异常的快照。当我调用它时,我的活动没有运行。 [图片链接]http://s13.postimg.org/pjlwlsnuv/errorpng.png 据我所知,当它试图达到 getsettings() 函数时,错误发生在某处。如果您有答案,请在此下方发布。如果您希望我提供更多详细信息,请对此问题发表评论。谢谢。
【问题讨论】:
-
您的 webview 对象为空。请检查 webview id 的布局 xml!
-
好的!我将添加一个答案使其被接受
标签: android xml exception webview error-handling