Reputation: 119
I have a Fragment in a ViewPager, and I want to access a View in said Fragment in order to change its background from the FragmentActivity.
I've been trying with every answer related I could find. No luck yet. Any ideas?
-R
Upvotes: 1
Views: 703
Reputation: 1811
ViewPager
Adapter to send back Fragments
getItem()
function, along with returning the fragment add it in an array as well.. this will keep track of instantiated fragments based on their position.get
the fragment you need, then retrieve the view from that fragment.Upvotes: 1
Reputation: 3263
Try this to get your fragment :
YourFrag frag = (YourFrag) viewPager.getAdapter().instantiateItem(viewPager, pageNumber);
then you can get the views as usual
frag.getView().findViewById() ...
or however you like.
Upvotes: 1