I'm having a bit of trouble with communication between a parentActivity and its child fragment.
I am using actionbarsherlock.
I have looked around on SO, but I haven't found something that deals with ViewPagers and Spinners yet.
Background:
My child fragment has its own action bar specifying a couple of extra action items not available in other fragments, one of these action items is a spinner with multiple options - A, B and C etc
By default the MainActivity will load Fragment_A(child fragment) which contains a ViewPager.
This view pager handles swipes between views A and B(Spinner has options A,B, C etc)
Fragment_A also has spinner adapter. If you select A on the spinner, the viewPager switches to A, if you select B on the spinner, the viewPager switches to B. (This works fine).
My question is: How do I capture when the user "swipes" between A and B(They don't use the spinner) and change my "spinner" to say A or B respectively?
Note: My pager adapter(for ViewPager) is created separately in a different class.
Any help is appreciated...Thank you all!
This is what you need. You'll have to set up an interface
in your Fragment
and implement that interface
in the parent activity. In your Fragment
instantiate an instance of the interface
and in whatever method you use to listen to page changes, call the method to communicate that data to the activity.
It seems kinda "hand-wavy" but I hope that clears it up a little.