handle DialogFragment with orientaion change

To handle DialogFragment with orientaion change:
  • Override onActivityCreated() to call setRetainInstance(true)

    Example:

      @Override
    public void onActivityCreated(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onActivityCreated(savedInstanceState);
    setRetainInstance(true);
    }

  • Override onDestroyView() to dismiss message quere

    Example:

      @Override
    public void onDestroyView() {
    if (getDialog() != null && getRetainInstance()){
    getDialog().setDismissMessage(null);
    }
    super.onDestroyView();
    }


0 Response to "handle DialogFragment with orientaion change"

Posting Komentar