title: How to get the view of a Fragment outside of OnCreateView()
body: <p>I have a <code>Fragment</code> with a <code>TableLayout</code>. The data in the table is from a SQLite db. The SQLite db is populated from a RESTful webservice in an <code>AsyncTask</code> in the <code>MainActivity</code>. The <code>Fragment</code> must wait for the task to complete before populating the table. The <code>Fragment</code> listens for the task <code>onPostExecute()</code> method to be called. When it is, the method <code>onLoadAndStoreComplete()</code> in the <code>Fragment</code> is called. This all works.</p>
  
  <p>I need to get a view of a <code>TableLayout</code> outside the <code>OnCreateView()</code> method of a Fragment. If I could get the View of the fragment in <code>onLoadAndStoreComplete</code> that would get me there.</p>
  
  <p><a href="https://stackoverflow.com/questions/29569170/get-fragment-activity-outside-of-fragment-oncreateview">Same code as here.</a>
  I've got <code>mContext</code> from the MainActivity, but that has no <code>getView()</code> method associated with it.</p>
  
  <p>I've tried:<br>
  - making a class member rootView and assigning in onCreateView(), but in <code>onLoadAndStoreComplete()</code>, it is null.<br>
  - making a class member tableLayout and assigning in onCreateView(), but in <code>onLoadAndStoreComplete()</code>, it is null.<br>
  - calling this.getView() again in <code>onLoadAndStoreComplete()</code>, but it returns null.<br>
  - calling the inflator inside  <code>onLoadAndStoreComplete()</code>, which works, but then I don't know what to use for container in the <code>.inflate()</code> call  </p>
  
  <p>I don't understand why the class member values of rootView and tableLayout are null in <code>onLoadAndStoreComplete()</code></p>
  
  <pre><code>public class MyFragment extends Fragment implements OnLoadAndStoreCompleteListener {
  
  private TableLayout tableLayout;
  private View rootView;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,  Bundle savedInstanceState) {
          mContext = this.getActivity();
          rootView = inflater.inflate(R.layout.fragment_permits, container, false); // this works
          tableLayout = (TableLayout) rootView.findViewById(R.id.main_table); // and this
          ...
      }
  
      @Override
      public void onLoadAndStoreComplete() {
  
         // rootView is null, ie not remembered from OnCreateView
  
          View view =  getView(); // null
  
          LayoutInflater inflater = LayoutInflater.from(getActivity());
        rootView = inflater.inflate(R.layout.fragment_permits, container, false); // container? don't know what it should be
  
          // tableLayout is null
          tableLayout.addView(tableRow, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
      }
      ...
  }
  </code></pre>