I used a tab layout with fragment. The scenario goes like this.
Activity:
Fragment 1 , Fragment2 , Fragment3
From Fragment2 Updating the UI of Fragment1.
I tried to access the methods from fragment but resulting null pointer exception.
I used a tab layout with fragment. The scenario goes like this.
Activity:
Fragment 1 , Fragment2 , Fragment3
From Fragment2 Updating the UI of Fragment1.
I tried to access the methods from fragment but resulting null pointer exception.
Observer Pattern
to achieve this. To do this, You have to create aMutableLiveData
in yourMainActivity
and pass it tofragment
throughinterface
.Create interface:
Implements this in
Activity
:Inside FragmentA:
...
Inside FragmentB:
...