title: ViewPager NullPointerException while modifying FragmentActivity in Fragment
body: <p>I'm trying to modify an old FragmentActivity hosting a view pager with 3 listview in a Fragment. 
  The Fragment class has code that is similar to an Activity. In fact, when converting an existing Android application to use fragments, I though it would have been sufficient to  move code from the activity's callback methods into the respective callback methods of the fragment. But it didn't work. I get a NullPointerException at the line</p>
  
  <pre><code>mViewPager.setAdapter(mAppSectionsPagerAdapter);
  </code></pre>
  
  <p>here is the code:</p>
  
  <pre><code>public class FragmentAllEvents extends Fragment implements ActionBar.TabListener 
  {
      AppSectionsPagerAdapter mAppSectionsPagerAdapter;
  
      // JSON Node names
      private static final String TAG_UID = "uid";
      private static final String TAG_LOGO = "logo";
      private static final String TAG_POKUID = "pokuid";
  
      static ArrayList&lt;HashMap&lt;String, String&gt;&gt; userList;
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; userListTotal;
      HashMap&lt;String, String&gt; userSelected;
      EventsFunctions eventsFunctions;
      UserFunctions userFunctions;
      /**
       * The {@link ViewPager} that will display the three primary sections of the app, one at a
       * time.
       */
      ViewPager mViewPager;
      static ListView lv;
      ActionBar actionBar;
  
      //Context context = this;
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) 
      {
          super.onCreate(savedInstanceState);
  
          View v = inflater.inflate(R.layout.all_events_main, container, false);
  
          Log.e("AllEventsFragmentActivity Report", "Entering AllEventsFragments");
          // Create the adapter that will return a fragment for each of the three primary sections
          // of the app.
          //FragmentManager fm = getSupportFragmentManager();
          mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getFragmentManager());
  
          // Set up the action bar.
          actionBar = getActivity().getActionBar();
  
          // Specify that the Home/Up button should not be enabled, since there is no hierarchical
          // parent.
          actionBar.setHomeButtonEnabled(true);
  
          // Specify that we will be displaying tabs in the action bar.
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  
          // Set up the ViewPager, attaching the adapter and setting up a listener for when the
          // user swipes between sections.
          mViewPager = (ViewPager) getActivity().findViewById(R.id.pager_main);
          mViewPager.setAdapter(mAppSectionsPagerAdapter);
          // Defining a listener for pageChange 
          mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() 
          {
              [...]
          });
  
          [...]
  }
  </code></pre>
  
  <p>In the previous version of this class I was extending FragmentAllEvents with a FragmentActivity instead of a Fragment.</p>