Problem: Upon clicking a button in a fragment
inside of the ViewPager
the click falls through to the fragment
that is behind it and registers the onClickListener()
in the behind fragment
rather than the current fragment’s onClickListener()
.
Situation: I have a ViewPager
with 4 fragments
in it. Each fragment
contains a few rows of custom made buttons. Each fragment
has it’s own unique view/layout
, yet they are all designed similarly.
Set Up: I am using the FragmentPagerAdapter
, because I have a short list of pretty static fragments
AND because I need to communicate and update each fragment
by using an interface
, like how the developer docs suggest.
My Idea: Should I switch to the FragmentStatePagerAdapter
? So the adapter
will destroy the fragments
when they are not visible? But in doing this, will I not be able to communicate with the fragments
and update them accordingly?
I don’t know how to solve this problem and it has been driving me mad! Any help is appreciated.
Ask me if I need to clarify anything.