I have a ViewPager whose pages are scrolled using tabs. Well, I did something on the second page, assigned Boolean changed = true; , now, by clicking on tab1 (Well, or flipping the screen)), somehow I want:

1. Forward this variable to the first page.
2. How to get it on the first page
3. If the variable is true , for example, display a toast with the text changed

How is this possible to do? Well, the result should be this - on the first page I have a variable that I can use.

    1 answer 1

    1. Create a callback interface, and using it, notify the Activity or adapter ViewPager 'a about the data change
    2. Use an event library, such as an EventBus .
    3. Use BroadcastReceiver , for example, LocalBroadcastReceiver to notify
    • What is the fastest or most convenient? - Mr Klonwar
    • one
      @MrKlonwar; If you only need to notify the classes in this place in the reverse order , then the first option. If it is necessary for other classes to react to this event at the same time, then the second or third. I personally use the third, but I usually have all the components of the application exchange information with it - Vladyslav Matviienko