Wednesday, 10 October 2018

DialogFragment with multiple fragments/views

How can I display a dialogfragment with multiple fragments one after the other with animation?

The use case I have is:

  1. DialogFragment is showing with fragment 1. It has a "next" button
  2. User clicks next
  3. The same dialogFragment displays fragment 2 with a slide in animation.

Any pointers would help.

Thank you in advance.

This is the base dialogfragment I am using

public class BaseDialogFragment extends DialogFragment {

    public BaseDialogFragment () {

    }

    public static BaseDialogFragment newInstance(String title) {
        BaseDialogFragment frag = new BaseDialogFragment ();
        Bundle args = new Bundle();
        args.putString("title", title);
        frag.setArguments(args);
        return frag;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment, container);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);


        getDialog().getWindow().setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    }
}

Here is how the behaviour is. It is BottomNavigation activity that is displaying dialog with flow. The next/previous dialog comes in with slide in/out navigation.

enter image description here

I am open to other suggestions too such as dialog-Themed activity



from DialogFragment with multiple fragments/views

No comments:

Post a Comment