@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_eight, container, false);
mWebView = (WebView) mWebView.findViewById(R.id.fragment_eight_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("http://facebook.com/");
}
问题:
Error:(29, 9) error: unreachable statement
Error:(33, 5) error: missing return statement
问题显示在上一行的第5行
答案 0 :(得分:0)
你有死代码,你在函数顶部返回:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_eight, container, false);
mWebView = (WebView) mWebView.findViewById(R.id.fragment_eight_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("http://facebook.com/");
}
替换为
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_eight, container, false);
mWebView = (WebView) view.findViewById(R.id.fragment_eight_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("http://facebook.com/");
return view;
}
答案 1 :(得分:0)
返回行需要到方法的末尾。
在这种情况下,这一行。
return inflater.inflate(R.layout.fragment_eight, container, false);