java.lang.NullPointerException: Attempt to invoke virtual method 'void android.webkit.WebView.loadUrl(java.lang.String)' on a null object reference
public class Tab3 extends Fragment { WebView web; @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.tab_2, container, false); web=(WebView)v.findViewById(R.id.webView1); // Force links and redirects to open in the WebView instead of in a browser //web.setWebViewClient(new WebViewClient()); web.loadUrl("http://www.google.com"); return v; } }
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <WebView android:id="@+id/webView1" android:layout_width="wrap_content" android:layout_height="wrap_content"> </WebView> </RelativeLayout>
findViewById(R.id.webView1)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)