pass data to another fragment by swipe view with tab android studio,not button

后端 未结 4 759
别那么骄傲
别那么骄傲 2020-12-11 04:05

Is it possible to pass a data from fragment to fragment by swipe?

There are many articles teaching us how to pass the data from fragment to fragment, but most of t

4条回答
  •  醉酒成梦
    2020-12-11 05:05

    Although C James provides good tips to solve your problems, I would like to introduce another way without using implementing of interfaces. Please check below link out. If you use an event bus library such a http://square.github.io/otto/, you can easily pass data you want to share among fragments and even activities. Additionally, you can reduce a lot of code line since it only requires Sender(PUBLISHING), Receiver(Subscriber) while implementation of interfaces requires additional lines of code. Here is a tutorial of Otto libarary. http://www.vogella.com/tutorials/JavaLibrary-EventBusOtto/article.html

    Hope it helps :)

提交回复
热议问题