I did a bottomnavigationview with two tabs, then I injected fragments at each of the tabs, I would like to know how to communicate the 2 tabs.
for example, creating an EditText with a button at the first tabs and then retrieving the information at the level of this tab and injecting it into a TextView at the level of the second.
I already tried with the bundle but it did not work when I click on the tabs that must retrieve the information the app stops showing "unfortunately appname has stopped".
Asked
Active
Viewed 172 times
-1

Phantômaxx
- 37,901
- 21
- 84
- 115

Begginers
- 35
- 2
- 5
1 Answers
0
It is not recommended to use BottomNavigation with just 2 tabs. Use Tabs instead. Read more.
To communicate between fragments in one activity, just use ViewModel and LiveData from Android Architecture Components.
Tips:
- Follow the guidance here on how to share ViewModel data between fragments in one activity. Read more
- In the first fragment, bind the the EditText to LiveData.
- In the second fragment, observe the LiveData and show it to TextView.

Yosi Pramajaya
- 3,895
- 2
- 12
- 34