title: IllegalStateException: DialogFragment can not be attached to a container view - (in ActionBarActivity)
body: <p>In my <strong>Activity (that extends android.support.v7.app.ActionBarActivity)</strong> I have a fragment that is normally include into my views like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:tools="http://schemas.android.com/tools"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       &gt;
       &lt;fragment 
        android:name="com.fragments.SomeFragment"
        android:id="@+id/fragment_id"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>That works well.</p>
  
  <p>But I've decided to reuse this fragment as a dialog, so I extended it by <strong>android.support.v4.app.DialogFragment</strong> (from supported library).</p>
  
  <p>Without any other changes I get the exception</p>
  
  <pre><code> java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ExampleActivity}: java.lang.IllegalStateException: DialogFragment can not be attached to a container view
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
  at android.app.ActivityThread.access$600(ActivityThread.java:141)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:5041)
  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:793)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  at dalvik.system.NativeStart.main(Native Method)
  
      Caused by: java.lang.IllegalStateException: DialogFragment can not be attached to a container view
  at android.support.v4.app.DialogFragment.onActivityCreated(DialogFragment.java:364)
  at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1486)
  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1086)
  at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1877)
  at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:552)
  at com.*.RoboActionBarActivity.onStart(RoboActionBarActivity.java:58)
  at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1164)
  at android.app.Activity.performStart(Activity.java:5114)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153)
  ... 11 more
  </code></pre>
  
  <p>How can I resolve this problem or use my standard fragment as a dialog?</p>
  
  <p>My Activity:</p>
  
  <pre><code>public class SomeActivity extends RoboActionBarActivity{
  
      private SomeFragment someFragment;
  
      @Override
      protected void onCreate(final Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.actvity_some);
  
          this.someFragment = (SomeFragment) getSupportFragmentManager().findFragmentById(
              R.id.fragment_id);
      }
  }
  </code></pre>
  
  <p>RoboActionBarActivity is a ActionBarActivity that implements RoboContext (from RoboGuice) to enable injection.</p>
  
  <pre><code>public class RoboActionBarActivity extends ActionBarActivity implements RoboContext {
  private EventManager eventManager;
  private final HashMap&lt;Key&lt;?&gt;, Object&gt; scopedObjects = new HashMap&lt;Key&lt;?&gt;, Object&gt;();
  
  @Inject
  private ContentViewListener ignored; // BUG find a better place to put this
  
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
      final RoboInjector injector = RoboGuice.getInjector(this);
      this.eventManager = injector.getInstance(EventManager.class);
      injector.injectMembersWithoutViews(this);
      super.onCreate(savedInstanceState);
      this.eventManager.fire(new OnCreateEvent(savedInstanceState));
  }
  
  @Override
  protected void onRestart() {
      super.onRestart();
      this.eventManager.fire(new OnRestartEvent());
  }
  
  @Override
  protected void onStart() {
      super.onStart();
      this.eventManager.fire(new OnStartEvent());
  }
  
  @Override
  protected void onResume() {
      super.onResume();
      this.eventManager.fire(new OnResumeEvent());
  }
  
  @Override
  protected void onPause() {
      super.onPause();
      this.eventManager.fire(new OnPauseEvent());
  }
  
  @Override
  protected void onNewIntent(final Intent intent) {
      super.onNewIntent(intent);
      this.eventManager.fire(new OnNewIntentEvent());
  }
  
  @Override
  protected void onStop() {
      try {
          this.eventManager.fire(new OnStopEvent());
      } finally {
          super.onStop();
      }
  }
  
  @Override
  protected void onDestroy() {
      try {
          this.eventManager.fire(new OnDestroyEvent());
      } finally {
          try {
              RoboGuice.destroyInjector(this);
          } finally {
              super.onDestroy();
          }
      }
  }
  
  @Override
  public void onConfigurationChanged(final Configuration newConfig) {
      final Configuration currentConfig = getResources().getConfiguration();
      super.onConfigurationChanged(newConfig);
      this.eventManager.fire(new OnConfigurationChangedEvent(currentConfig, newConfig));
  }
  
  @Override
  public void onContentChanged() {
      super.onContentChanged();
      RoboGuice.getInjector(this).injectViewMembers(this);
      this.eventManager.fire(new OnContentChangedEvent());
  }
  
  @Override
  protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      this.eventManager.fire(new OnActivityResultEvent(requestCode, resultCode, data));
  }
  
  @Override
  public Map&lt;Key&lt;?&gt;, Object&gt; getScopedObjectMap() {
      return this.scopedObjects;
  }
  }
  </code></pre>