title: View is null in Fragment
body: <p>I have a number of fragments within a <code>ViewPager</code> in one of my activities. These fragments have text on them. My goal is to update the text on the fragments when an event happens in my activity. </p>
  
  <p>I have tried some things, but I cannot seem to find a view to work with. In the below code I have tried to save the view from the <code>onCreateView</code> to a private field. This works successfully when creating my fragment, but when I try and call <code>refresh</code> my <code>mView</code> is null.</p>
  
  <p><code>refresh</code> is implemented in an interface. My <code>ViewPager</code> has 2 different fragments, so I implemented the interface to allow me to cast an unknown fragment to call refresh. </p>
  
  <p>I have tried to write the below code to best illustrate my problem. I can set the text to "Hello" but on refresh, the activity will crash because <code>mView</code> is null.</p>
  
  <pre><code>    private View mView = null;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          if (container == null) { return null; }         
          View view = inflater.inflate(R.layout.view_account_general, container, false);
          mView = view;
          setContent();
          return view;
      }
  
      private void setContent() {
          if (mView == null) return;
          ((TextView) mView.findViewById(R.id.mId)).setText("Hello");
      }
  
      @Override
      public void refresh() {
          ((TextView) mView.findViewById(R.id.mId)).setText("Test");
      }
  </code></pre>
  
  <p>What am I doing wrong and what should I be doing instead? Fragments are very new to me and I haven't programmed for Android in a long time. My only intention is to update the value of my <code>TextView</code> when the <code>refresh</code> method is called.</p>
  
  <p>Thank you for any attempts at helping me with my issue! </p>
  
  <p>Edit:
  As requested, the exception trace.</p>
  
  <pre><code>FATAL EXCEPTION: main
  java.lang.NullPointerException
      at com.jordanmoore.finances.AccountGeneralFragment.refresh(AccountGeneralFragment.java:85)
      at com.jordanmoore.finances.AccountActivity.onOptionsItemSelected(AccountActivity.java:222)
      at android.app.Activity.onMenuItemSelected(Activity.java:2534)
      at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
      at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:964)
      at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
      at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
      at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
      at com.android.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:156)
      at android.widget.AdapterView.performItemClick(AdapterView.java:298)
      at android.widget.AbsListView.performItemClick(AbsListView.java:1090)
      at android.widget.AbsListView$PerformClick.run(AbsListView.java:2863)
      at android.widget.AbsListView$1.run(AbsListView.java:3538)
      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:4786)
      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>