我正在製作一個使用滑動菜單片段的webview瀏覽器。當我打開這個片段時,應用程序崩潰。我是新來的碎片,所以我很抱歉,如果這是不懂的。如果還有其他事情可以幫助解決這個問題,那就問問。崩潰片段
下面是片段類
public class WhatsHotFragment extends Fragment {
public WhatsHotFragment(){}
WebView WebViewB;
ProgressBar Pbar6;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_whats_hot, container, false);
Pbar6 = (ProgressBar) getView().findViewById(R.id.progBar6);
WebViewB = (WebView) getView().findViewById(R.id.wvBrowserAesir);
WebSettings webSettings = WebViewB.getSettings();
webSettings.setJavaScriptEnabled(true);
WebViewB.getSettings().setLoadWithOverviewMode(true);
WebViewB.getSettings().setUseWideViewPort(true);
WebViewB.getSettings().setBuiltInZoomControls(true);
WebViewB.getSettings().setAllowFileAccess(true);
WebViewB.setWebViewClient(new InsideWebViewClient());
WebViewB.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
if(progress < 100 && Pbar6.getVisibility() == ProgressBar.VISIBLE){
Pbar6.setVisibility(ProgressBar.VISIBLE);
}
Pbar6.setProgress(progress);
if(progress == 100) {
Pbar6.setVisibility(ProgressBar.VISIBLE);
}
}
});
{
WebViewB.loadUrl("http://www.google.com");
}
return rootView;
}
}
提前感謝!
請發佈堆棧跟蹤。 – Emmanuel