I have Activity
with ViewPager
. There is a button in the Activity that should change it's visibility depending on which item (fragment) is shown on the screen.
Problem: I can't access the button from within fragment because findViewById() call returns null when invoked from the inside of fragment code. I also thought I could notify activity about fragment state change but the code from the documentation is already deprecated.
Question: How to change a button within an activity when a particular fragment appears/disappears on the screen?
Note: Getting a current fragment is not a problem. I need to detect that fragment is changed.