I am trying to start a new Activity form Fragment. I keep getting the following error:

```
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference

```

Here is my code:

```
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

public class Tap1 extends Fragment {

private Button button;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view=inflater.inflate(R.layout.content_tap1,container,false);

    button = (Button) getView().findViewById(R.id.button);

    return  view;
}

public void faceMask(View v)
{
    Intent i = new Intent(getActivity(), ShoppingCart.class);
    startActivity(i);
}

}

```

Here is the xml file(layout):

```
<?xml version="1.0" encoding="utf-8"?>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.amer.dentalhouse.Tap1">

       <ScrollView
       android:layout_width="match_parent"
       android:layout_height="match_parent">
       <RelativeLayout    
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <Button 
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Face Mask"
            android:id="@+id/button"
            android:drawableTop="@drawable/facemask"
            android:layout_alignParentTop="true"
            android:layout_alignLeft="@+id/button1"
            android:layout_alignStart="@+id/button1"
            android:clickable="true"
            android:onClick="faceMask" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Barieer"
            android:id="@+id/button1"
            android:drawableTop="@drawable/barieer"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginTop="320dp" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Dispnser"
            android:id="@+id/button2"
            android:drawableTop="@drawable/dispnser"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginTop="700dp" />

    </RelativeLayout>

    </ScrollView>

    </LinearLayout>

```

Here's the entire error I get from one run after clearing the logcat

```
    : FATAL EXCEPTION: main
  Process: com.example.amer.dentalhouse, PID: 24812
  java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference
      at com.example.amer.dentalhouse.Tap1.onCreateView(Tap1.java:23)
      at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
      at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
      at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
      at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
      at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1106)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:952)
      at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1474)
      at android.view.View.measure(View.java:17951)
      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5797)
      at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
      at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
      at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
      at android.view.View.measure(View.java:17951)
      at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:940)
      at android.view.View.measure(View.java:17951)
      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5797)
      at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
      at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
      at android.view.View.measure(View.java:17951)
      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5797)
      at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
      at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
      at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
      at android.view.View.measure(View.java:17951)
      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5797)
      at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
      at android.view.View.measure(View.java:17951)
      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5797)
      at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
      at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
      at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
      at android.view.View.measure(View.java:17951)
      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5797)
      at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
      at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2910)
      at android.view.View.measure(View.java:17951)
      at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2048)
      at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1185)
      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1406)
      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1073)
      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5988)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
      at android.view.Choreographer.doCallbacks(Choreographer.java:580)
      at android.view.Choreographer.doFrame(Choreographer.java:550)
      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:135)
      at android.app.ActivityThread.main(ActivityThread.java:5910)
      at java.lang.reflect.Method.invoke(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:372)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
    a

```