Detailed explanation of data transfer examples between two fragments of Android

How to transfer data between two fragments of Android

Fragmenta starts fragmentb and returns to fragmenta after making some selection operations. You need to transfer the selected data in fragmentb back. What can I do?

Fragments cannot communicate directly with each other. They must be completed through activity. Please refer to the specific steps.

1. Define a communication interface in fragmenta and send data to activity through this interface.

2. Implement the interface in the activity and transfer data to fragmentb through the interface.

3. Fragmentb receives data and processes it.

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>