-2

I have Two "Child"Fragment and a "Parent"Fragment, so how I can pass data between that "Child"Fragments?? thanks everyone!!

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0
Create newInstance() of ClidFragment and set the arguments--

public static ClidFragment newInstance(String arg1, String agr2) {
        ClidFragment fragment = new ClidFragment();
        Bundle args = new Bundle();
        args.putString(Key_arg1, arg1);
        args.putString(Key_arg2, arg2);
        fragment.setArguments(args);
        return fragment;
    }

Receive arguments in ClidFragment Fragment--
(Write this code in on create)
            Bundle args = getArguments();
            String arg1 = args.getString(Key_arg1);
            String arg2 = args.getString(Key_arg2);

SetArgument form Parent Fragment --
When you are replacing fragment then set The argument like this-
ClidFragment childFragment= ClidFragment.newInstant(arg1,arg2);
then replace your fragment using childFagment.

//Hope this help you
Shiv Jalkote
  • 111
  • 6