title: android get activity returns null
body: <p>I am using Action Bar on an Activity. For each Tab I am showing different layout. Since the layout is too heavy. So I am inflating each layout into a view. So on each Tab select </p>
  
  <pre><code>public void onTabSelected(Tab tab, FragmentTransaction ft) {
      if (mView == null) {
          mView = LayoutInflater.from(mAct).inflate(mLayout, null);  // mAct is Activity reference
      }
      mAct.setContentView(mView);
      for (int i = 0; i &lt; mFrags.length; i++) {
       mFrags[i] = (LutronFragment) mAct.getFragmentManager()
           .findFragmentById(mIds[i]);
  
       if (mFrags[i] != null) {
         mFrags[i].setupHeader();
        }
    }
  }
  public void onTabUnselected(Tab tab, FragmentTransaction ft) {
    for (Fragment f : mFrags) {
     try { 
           if (f != null) {
          ft.remove(f);
        }
    } catch (IllegalStateException e) {
          e.printStackTrace();
    }
     }
  }
  </code></pre>
  
  <p>So Now if I select tab second time and do some operation on that Tab, app get crashed on getActivity.(NullPointerException)</p>
  
  <p>Please suggest if there is some another approach to cache heavy layout.</p>