I have a problem that has my application stopped. I have an activity with several fragments of which I need to fire the event of one of the menu buttons, collect its data and send it to another activity to display it in the fragments for said activity.
Simply send the data you have in the fragment through a bundle, when it is received by the second activity you can use it in its respective fragment.
in the second Activity, inside your onCreate() method:
Here receiving the data from the bundle, they can be used in the fragment that has your second activity.
You can use:
In the Source Fragment before processing beginTransaction()
In the onCreateView of the target Fragment you can get the / them and save them wherever you want.
You can send more, as many as you need:
Of course you can also pass other data types (String, int, float, etc)
See: http://developer.android.com/intl/es/reference/android/os/Bundle.html
I have had that problem too!
When you want to pass DATA between two Fragments, you must use the class
Bundle
(package in Spanish, in computing terminology) once created, you must add a .putString(Key, Value), .putInt(Key, Value).. .And in the other
Fragment
where you receive the data, you do aBundle b = getArguments();
and then if it is an int, for example you do ab.getInt(Key,valorPorDefecto)