I want to pass data between two fragments without using activity and fragment activity.
I don't want to pass data between fragments using activity like this : Communicating with Other Fragments
Below is my scenario :
I have one Parent fragment and inside that there are two child fragments.Now my need is to pass data between these two fragments.How to achieve this?
I looked into this : Event Bus but not getting working example for fragments.
Is there any other alternative to pass data between fragments?
Any help will be appreciated.
Edited as per InnocentKiller's answer :
In FragmentOne , I have implemented :
FragmentTwo = new FragmentTwo();
Bundle bundle = new Bundle();
bundle.putString("Hello", "My name is Siddharth");
fragment.setArguments(bundle);
In FragmentTwo, I have implemented :
Bundle bundle = this.getArguments();
String myInt = bundle.getString("Hello","Test");
mStartTripButton.setText(myInt);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…