title: Calling context in a FirebaseListAdapter (Android)
body: <p>I created a tabbed activity that contains three fragments. I get a NullPointerException whenever I scroll to my ListFragment that used a FirebaseListAdapter. I suspect it has something to do with the context parameter in the FirebaseListAdapter. I read in other posts that <code>getActivity()</code> should be used on Fragments but it didn't work in my case.</p>
  
  <p>Here's my fragment class that catches the error:</p>
  
  <pre><code>public class ActionPlan extends ListFragment {
  
  
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.activity_action_plan, container, false);
      getActionPlan(rootView);
      return rootView;
  }
  
  
  
  public void getActionPlan(final View view){
  
      Firebase ref = new Firebase("https://infotrack.firebaseio.com/infotrack/rso/actionplan");
  
      ListView ap = (ListView) view.findViewById(R.id.list);
  
      FirebaseListAdapter&lt;ApContent&gt; apAdapter = new FirebaseListAdapter&lt;ApContent&gt;(getActivity(), ApContent.class, R.layout.layout_action_plan, ref) {
          @Override
          protected void populateView(View view, ApContent content, int position) {
  
              ((TextView) view.findViewById(R.id.txtActivity)).setText(content.getActivity());
              ((TextView) view.findViewById(R.id.txtTimeframe)).setText("TIMEFRAME: " +content.getTimeframe());
              ((TextView) view.findViewById(R.id.txtCorevalues)).setText("CORE VALUES: " +content.getCorevalues());
              ((TextView) view.findViewById(R.id.txtObjective)).setText("OBJECTIVE: " +content.getObjective());
              ((TextView) view.findViewById(R.id.txtStrategy)).setText("STRATEGY: " +content.getStrategy());
              ((TextView) view.findViewById(R.id.txtManpower)).setText("MANPOWER: " +content.getManpower());
              ((TextView) view.findViewById(R.id.txtBudget)).setText("BUDGET PROPOSAL: " +content.getBudget());
  
          }
      };
  
      ap.setAdapter(apAdapter);       
  }
  </code></pre>
  
  <p>}</p>
  
  <p>stacktrace:</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
  
    java.lang.NullPointerException
        at xyz.kimfeliciano.infotrack.infotrack.ActionPlan.getActionPlan(ActionPlan.java:47)
        at xyz.kimfeliciano.infotrack.infotrack.ActionPlan.onCreateView(ActionPlan.java:20)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
        at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
        at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:490)
        at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1105)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:951)
        at android.support.v4.view.ViewPager$3.run(ViewPager.java:250)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
        at android.view.Choreographer.doCallbacks(Choreographer.java:555)
        at android.view.Choreographer.doFrame(Choreographer.java:524)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
        at android.os.Handler.handleCallback(Handler.java:615)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:213)
        at android.app.ActivityThread.main(ActivityThread.java:4787)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
        at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>the error points at these lines: <code>ap.setAdapter(apAdapter);</code> and <code>getActionPlan(rootView);</code></p>