加载 webview 时出错
error while loading the webview
我在片段中使用了 webview。
private void LoadWebView()
{
privacy_Webview.getSettings().setJavaScriptEnabled(true);
privacy_Webview.setWebViewClient(new WebViewClient());
privacy_Webview.loadUrl("http://www.google.com");
}
我遇到错误
java.lang.NullPointerException: Attempt to invoke virtual method 'android.webkit.WebSettings android.webkit.WebView.getSettings()' on a null object reference
错误发生在行:-
privacy_Webview.getSettings().setJavaScriptEnabled(真);
从一个片段单击按钮时,该片段会加载它具有 Web 视图的内容。
我想不通这个问题。
您的 fragment_forgot_password
似乎不包含 wv_privacy
,所以 rootView.findViewById(R.id.wv_privacy)
returns null
.
我在片段中使用了 webview。
private void LoadWebView()
{
privacy_Webview.getSettings().setJavaScriptEnabled(true);
privacy_Webview.setWebViewClient(new WebViewClient());
privacy_Webview.loadUrl("http://www.google.com");
}
我遇到错误
java.lang.NullPointerException: Attempt to invoke virtual method 'android.webkit.WebSettings android.webkit.WebView.getSettings()' on a null object reference
错误发生在行:- privacy_Webview.getSettings().setJavaScriptEnabled(真);
从一个片段单击按钮时,该片段会加载它具有 Web 视图的内容。
我想不通这个问题。
您的 fragment_forgot_password
似乎不包含 wv_privacy
,所以 rootView.findViewById(R.id.wv_privacy)
returns null
.