I've been struggling with this for quite some time now, a lot of people suggested that one uses the FragmentManager to rebuild the fragment (such as Show hide fragment in android ,among other methods). Here is my situation:
- I have the MainActivity telling the Fragment it should update itself. Fine until here.
- The correct Fragment is receiving the instructions, and it tries to toggle the visibility of its Views (TextView, Button,etc), which, in theory, it does.
- Problem is, the Fragment's view, isn't updated, that is, the button's and textview's visibility does not change. How come? Oddly enough, for testing purposes, I placed my Fragment in 3 tabs at once, and they are actually updated, that is, when I cycle to them, their visibility is changed, and when I return to my tab, it is changed as well, that is, the visibility is now the intended.
Is this normal? Is there an official way to change this - one that's not "hacky" and involves rebuilding the Fragment?
Even stranger is, the toggle on the Fragment builds a Toast, which isn't shown. However if I simply create the Toast from the MainActivity (where the Fragment is), it works. Should I just toggle the visibility from the MainActivity? I would really like to avoid this.