I have an Activity with two fragments and I need to pass a string from FragmentA to FragmentB.
To pass the data, I have this in my FragmentA:
Int
to pass data between Fragments you can use setArguments(Bundle b). For instance:
public class FragmentA extends Fragment {
public static FragmentA newInstance(String name) {
Bundle bundle = new Bundle();
bundle.putString("name", name);
FragmentA f = new FragmentA();
f.setArguments(bundle);
return f;
}
}