Wednesday, May 16, 2012

DialogFragment orientation change

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:



@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(layoutId);
if (savedInstanceState == null)
initFragment();
}


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".



BTW I'm using ActionBarSherlock





No comments:

Post a Comment