I have a ViewPager
with several fragments using FragmentStatePageAdapter
.
I'm looking to implement something that will allow me to send a string of data that is entered into an EditText
from a fragment
to an activity
when the user swipes away from the fragment.
I've looked at OnPageChangeListener
and tried a couple of different things with that but as onPageSelected
gives you the fragment id
of the one you're moving onto I can't get the Layout View
of the fragment
to reference the EditText
I'm swiping away from. There will also be no set fragment that leads on to another i.e. Fragment
1 doesn't always lead to Fragment
2 etc.
I tried using the onDestroy()
of the fragment
but that doesn't seem to be called until I've swiped 2 fragments
away so that's no use either.
Does anyone have any suggestions as to what I could use to achieve this?
Thanks