title: DialogFragment orientation change
body: <p>I have an activty and two fragments. One of the fragments extends DialogFragment and shows some text.
  In my activity i have overriden onCreate method:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(layoutId);
      if (savedInstanceState == null)
          initFragment();
  }
  </code></pre>
  
  <p>initFragment() adds a fragment to a FrameLayout in my layoutId. If no DialogFragment is shown everything works fine, but in case DialogFragment instance is shown - orientation change throws IllegalStateException that fragment did not return View on the line "setContentView".</p>
  
  <p>BTW I'm using ActionBarSherlock</p>
  
  <pre><code>E/AndroidRuntime(19517): FATAL EXCEPTION: main
  E/AndroidRuntime(19517): java.lang.RuntimeException: Unable to start activity Co
  mponentInfo{ru.nixan.android/ru.nixan.android.Cards}: android.view.InflateException: B
  inary XML file line #30: Error inflating class &lt;unknown&gt;
  E/AndroidRuntime(19517):        at android.app.ActivityThread.performLaunchActiv
  ity(ActivityThread.java:1956)
  E/AndroidRuntime(19517):        at android.app.ActivityThread.handleLaunchActivi
  ty(ActivityThread.java:1981)
  E/AndroidRuntime(19517):        at android.app.ActivityThread.handleRelaunchActi
  vity(ActivityThread.java:3351)
  E/AndroidRuntime(19517):        at android.app.ActivityThread.access$700(Activit
  yThread.java:123)
  E/AndroidRuntime(19517):        at android.app.ActivityThread$H.handleMessage(Ac
  tivityThread.java:1151)
  E/AndroidRuntime(19517):        at android.os.Handler.dispatchMessage(Handler.ja
  va:99)
  E/AndroidRuntime(19517):        at android.os.Looper.loop(Looper.java:137)
  E/AndroidRuntime(19517):        at android.app.ActivityThread.main(ActivityThrea
  d.java:4424)
  E/AndroidRuntime(19517):        at java.lang.reflect.Method.invokeNative(Native
  Method)
  E/AndroidRuntime(19517):        at java.lang.reflect.Method.invoke(Method.java:5
  11)
  E/AndroidRuntime(19517):        at com.android.internal.os.ZygoteInit$MethodAndA
  rgsCaller.run(ZygoteInit.java:784)
  E/AndroidRuntime(19517):        at com.android.internal.os.ZygoteInit.main(Zygot
  eInit.java:551)
  E/AndroidRuntime(19517):        at dalvik.system.NativeStart.main(Native Method)
  
  E/AndroidRuntime(19517): Caused by: android.view.InflateException: Binary XML fi
  le line #30: Error inflating class &lt;unknown&gt;
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.createView(Layout
  Inflater.java:606)
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.createViewFromTag
  (LayoutInflater.java:680)
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.rInflate(LayoutIn
  flater.java:739)
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.rInflate(LayoutIn
  flater.java:742)
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.inflate(LayoutInf
  later.java:489)
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.inflate(LayoutInf
  later.java:396)
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.inflate(LayoutInf
  later.java:352)
  E/AndroidRuntime(19517):        at com.android.internal.policy.impl.PhoneWindow.
  generateLayout(PhoneWindow.java:2707)
  E/AndroidRuntime(19517):        at com.android.internal.policy.impl.PhoneWindow.
  installDecor(PhoneWindow.java:2767)
  E/AndroidRuntime(19517):        at com.android.internal.policy.impl.PhoneWindow.
  setContentView(PhoneWindow.java:247)
  E/AndroidRuntime(19517):        at com.actionbarsherlock.internal.ActionBarSherl
  ockNative.setContentView(ActionBarSherlockNative.java:119)
  E/AndroidRuntime(19517):        at com.actionbarsherlock.app.SherlockFragmentAct
  ivity.setContentView(SherlockFragmentActivity.java:309)
  E/AndroidRuntime(19517):        at ru.nixan.android.Cards.onCreate(Cards.java:53)
  E/AndroidRuntime(19517):        at android.app.Activity.performCreate(Activity.j
  ava:4465)
  E/AndroidRuntime(19517):        at android.app.Instrumentation.callActivityOnCre
  ate(Instrumentation.java:1049)
  E/AndroidRuntime(19517):        at android.app.ActivityThread.performLaunchActiv
  ity(ActivityThread.java:1920)
  E/AndroidRuntime(19517):        ... 12 more
  E/AndroidRuntime(19517): Caused by: java.lang.reflect.InvocationTargetException
  E/AndroidRuntime(19517):        at java.lang.reflect.Constructor.constructNative
  (Native Method)
  E/AndroidRuntime(19517):        at java.lang.reflect.Constructor.newInstance(Con
  structor.java:417)
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.createView(Layout
  Inflater.java:586)
  E/AndroidRuntime(19517):        ... 27 more
  E/AndroidRuntime(19517): Caused by: android.view.InflateException: Binary XML fi
  le line #7: Error inflating class fragment
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.createViewFromTag
  (LayoutInflater.java:697)
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.rInflate(LayoutIn
  flater.java:739)
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.inflate(LayoutInf
  later.java:489)
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.inflate(LayoutInf
  later.java:396)
  E/AndroidRuntime(19517):        at com.android.internal.widget.ActionBarView.&lt;in
  it&gt;(ActionBarView.java:236)
  E/AndroidRuntime(19517):        ... 30 more
  E/AndroidRuntime(19517): Caused by: java.lang.IllegalStateException: Fragment ru
  .nixan.android.fragments.BalanceFragment did not create a view.
  E/AndroidRuntime(19517):        at android.support.v4.app.FragmentActivity.onCre
  ateView(FragmentActivity.java:293)
  E/AndroidRuntime(19517):        at android.view.LayoutInflater.createViewFromTag
  (LayoutInflater.java:669)
  E/AndroidRuntime(19517):        ... 34 more
  W/ActivityManager(30340):   Force finishing activity ru.nixan.android/.Cards
  </code></pre>
  
  <p>ErrorDialog.java</p>
  
  <pre><code>public class ErrorDialog extends SherlockDialogFragment implements
          OnClickListener {
  
      public static final String FRAGMENT_TAG = "error";
  
      public static final String EXTRA_EXCEPTION = "exception";
  
      public static ErrorDialog getInstance(Exception excpetion) {
          ErrorDialog result = new ErrorDialog();
          Bundle data = new Bundle();
          data.putSerializable(EXTRA_EXCEPTION, excpetion);
          result.setArguments(data);
          return result;
      }
  
      // some methods that are not in lifecycle are not presented here.
  
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          setRetainInstance(true);
          setShowsDialog(true);
          AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
          builder.setTitle(R.string.dialogErrorTitle);
          builder.setPositiveButton(R.string.dialogDismissButton, this);
          Exception exception = (Exception) getArguments().getSerializable(
                  EXTRA_EXCEPTION);
          builder.setMessage(getErrorMessage(exception, getActivity()));
          return builder.create();
      }
  }
  </code></pre>
  
  <p>Activity:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_cards);
      if (savedInstanceState == null) {
          Uri data = getIntent().getData();
          if (data == null || PATH_MENU.equals(data.getLastPathSegment()))
              initMenuFragment();
          else if (PATH_CARDS.equals(data.getLastPathSegment()))
              initCardsFragment();
      }
  }
  
  private void showError(Exception exception) {
      ErrorDialog.getInstance(exception).show(getSupportFragmentManager());
  
  }
  </code></pre>