简体   繁体   中英

Sending data to a fragment already created

I have a problem here and would like to know if anyone can help me solve this. I have a ViewPager, with 2 fragments, fragment A and fragment B. This viewPager is inside a fragment, we will call FragmentMain. FragmentMain contains a search, I need to send to fragment A and fragment B, which was typed in searchView, then inside fragment A and fragment B, I can "work" with text typed in searchView. Thank you! i was try it's.

There are lot many ways or pattern to pass the data from fragment to fragment, I will list top two ways in the order of preference for cleaner & testable code:


UPDATE Otto is officially deprecated, however you can continue using it, As alternative use this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM