title: Re-loading Fragment from inside itself
body: <p>I have been trying to figure out how I would be able to refresh my Fragment from a menu button that is defined inside the Fragment. </p>
  
  <p>I have looked at <a href="https://stackoverflow.com/questions/14097225/reload-fragment">this question here</a> but I was hoping for a more detailed example on how I would be able to achieve this.</p>
  
  <p>Any help or Guidance would be appreciated, thanks. </p>
  
  <pre><code>@Override
  public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()) {
      case R.id.clear_cache:
          mImageFetcher.clearCache();
          Toast.makeText(getActivity(), R.string.clear_cache_complete_toast,
                  Toast.LENGTH_SHORT).show();
          break;
  
      case R.id.random:
  
          //Reload the fragment from here
  
          getActivity().getSupportFragmentManager().beginTransaction()
          .replace(R.id.gridView, new Fragment3())
          .commit();
  
  
          return true;
      }
      return super.onOptionsItemSelected(item);
  </code></pre>
  
  <p>XML:</p>
  
  <pre><code>        &lt;activity
          android:name="com.stackoverflow.question.ImageGridActivity"
          android:label="@string/app_name"
          android:screenOrientation="portrait"
          android:theme="@style/AppTheme" &gt;
          &lt;/activity&gt;
  </code></pre>
  
  <p>Crashes with:</p>
  
  <pre><code>12-04 09:48:27.636: E/AndroidRuntime(20461): FATAL EXCEPTION: main
  12-04 09:48:27.636: E/AndroidRuntime(20461): java.lang.UnsupportedOperationException: addView(View) is not supported in AdapterView
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at android.widget.AdapterView.addView(AdapterView.java:451)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at android.os.Handler.handleCallback(Handler.java:615)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at android.os.Handler.dispatchMessage(Handler.java:92)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at android.os.Looper.loop(Looper.java:213)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at android.app.ActivityThread.main(ActivityThread.java:4787)
   12-04 09:48:27.636: E/AndroidRuntime(20461):   at java.lang.reflect.Method.invokeNative(Native Method)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at java.lang.reflect.Method.invoke(Method.java:511)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
  12-04 09:48:27.636: E/AndroidRuntime(20461):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>When using @Matthew Mcveigh answer:</p>
  
  <pre><code>12-04 10:05:09.315: E/AndroidRuntime(21072): FATAL EXCEPTION: main
  12-04 10:05:09.315: E/AndroidRuntime(21072): java.lang.NullPointerException
  12-04 10:05:09.315: E/AndroidRuntime(21072):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:666)
  12-04 10:05:09.315: E/AndroidRuntime(21072):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
  12-04 10:05:09.315: E/AndroidRuntime(21072):    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440)
  12-04 10:05:09.315: E/AndroidRuntime(21072):    at android.os.Handler.handleCallback(Handler.java:615)
  12-04 10:05:09.315: E/AndroidRuntime(21072):    at android.os.Handler.dispatchMessage(Handler.java:92)
  12-04 10:05:09.315: E/AndroidRuntime(21072):    at android.os.Looper.loop(Looper.java:213)
  12-04 10:05:09.315: E/AndroidRuntime(21072):    at android.app.ActivityThread.main(ActivityThread.java:4787)
  12-04 10:05:09.315: E/AndroidRuntime(21072):    at java.lang.reflect.Method.invokeNative(Native Method)
  12-04 10:05:09.315: E/AndroidRuntime(21072):    at java.lang.reflect.Method.invoke(Method.java:511)
  12-04 10:05:09.315: E/AndroidRuntime(21072):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
  12-04 10:05:09.315: E/AndroidRuntime(21072):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
  12-04 10:05:09.315: E/AndroidRuntime(21072):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>