How can i call the first Fragment method into Second Fragment in android? -


explanation: have 1 activity contains navigationdrawer.when activity launched.it's first open default fragment , fragment contains tablayout has multiple fragment.

when default fragment open tabs setup viewpager.assume, on first tab there 1 button. when click on button want call default fragment method

senario like

fragment of navigationdrawer(default fragment)->tablayout fragment(position=0)->button inside tablayout position=0->click on button it's call navigationdrawer(default fragment) method.

please me solve out problem.

there 3 solutions:

  1. use localbroadcastreceiver , send intent 1 fragment , listen @ another

  2. use eventbus library

  3. use activity callback listener. @ fragment can take current activity @ onattach method


Comments