调用虚拟方法的异常尝试-WebView 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()函数时,错误会发生在某个地方。如果你有答案,请把它贴在下面。如果你想让我提供更多的细节,请评论这个问题。非常感谢。

您的网络视图为null,因为您尚未调用setContentView()

在进行任何findViewById()呼叫之前,请先呼叫setContentView()

您的webview对象为null。请检查布局xml中的webview id!

最新更新