I am trying to accomplish this but with no success. Currently the code is giving error as missing return statement.
There could be something wrong with my approach as well.
Your help would be appreciated.
public class TipsTabFragment extends Fragment {
private WebView wv1;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String url = "http://example.com";
RelativeLayout view = null;
wv1 = (WebView) view.findViewById(R.id.wv1);
LayoutInflater mInflater = (LayoutInflater) getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
wv1.loadUrl(url);
wv1.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
}
}
you need to inflate a view and return that one
public class TipsTabFragment extends Fragment {
private WebView wv1;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String url = "http://example.com";
View view = inflater.inflate(R.layout.some_layout, container, false);
wv1 = (WebView) view.findViewById(R.id.wv1);
wv1.loadUrl(url);
wv1.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
return view;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.