title: How to open a webview from imagebutton?
body: <p>I have three buttons in a fragment that when the user clicks on one it'll open a specific webpage within the application. When I try to run this code on the phone it crashes when I try to access the tab. </p>
  
  <p>My .java class is right here:</p>
  
  <pre><code>public class SocialMediaFragment extends Fragment {
  
  public ImageButton fbbutton;
  public ImageButton twbutton;
  public ImageButton igbutton;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
    View rootView = inflater.inflate(R.layout.fragment_socialmedia, container, false);
  
      fbbutton = (ImageButton) getActivity().findViewById(R.id.fbbutton);
      twbutton = (ImageButton) getActivity().findViewById(R.id.twbutton);
      igbutton = (ImageButton) getActivity().findViewById(R.id.igbutton);
  
      fbbutton.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
              Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/universityofhouston"));
              startActivity(browserIntent);
          }
      });
  
      twbutton.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
              Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("website"));
              startActivity(browserIntent);
  
          }});
  
      igbutton.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
              Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("website"));
              startActivity(browserIntent);
  
          }});
      return rootView;
  
  }
  }
  </code></pre>
  
  <p>And here is the fragment (XML) file I am using:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/uhwallpaper"&gt;
  
      &lt;ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/fbbutton"
          android:background="@drawable/fb"
          android:layout_marginStart="46dp"
          android:layout_centerVertical="true"
          android:layout_alignParentStart="true" /&gt;
  
  
      &lt;ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/twbutton"
          android:background="@drawable/twitter"
          android:layout_above="@+id/igbutton"
          android:layout_toEndOf="@+id/fbbutton"
          android:layout_marginStart="43dp" /&gt;
  
  
  
      &lt;ImageButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/igbutton"
          android:background="@drawable/instagram"
          android:layout_below="@+id/fbbutton"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="32dp" /&gt;
  
  
  
      &lt;ImageView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/socialslogan"
          android:background="@drawable/slogan_social"
          android:layout_alignParentTop="true"
          android:layout_alignParentStart="true"
          android:layout_marginTop="16dp" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I hope this is fixable! If you need any more information let me know.</p>
  
  <p>Here is my error report:</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageButton.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
          at info.teammumu.cougarcardapp.SocialMediaFragment.onCreateView(SocialMediaFragment.java:28)
  </code></pre>