I'm needing a way to pass data from multiple fragments to an activity. This data can only be sent to the activity when I change the fragment tab. To pass the data I am using the interface method, but I do not know in which function of the class fragment I can put the method that will take the text of the EditText and send to the activity through the interface.
Asked
Active
Viewed 36 times
0
-
Its only when you switch fragments, right? You could place the code in the onDetach() – João Alvares Neto Jan 19 '18 at 19:35
1 Answers
0
Is it important to pass the data only when the fragment changes? If not, you could add a callback to the edit text that calls the interface method your activity implements. This answer has some good examples on how to do that.

Andrey
- 31
- 6
-
Another way would be to fill all 10 fragments, and then send the 10 data to an object. And to send this data would be to push a button in the activity – Bruno Queiroz Jan 19 '18 at 19:59