0
votes

What i am doing is showing Fragment in view pager and has Gesture detector implemented on Whole view. When we touch the View i want to hide some layouts from current fragment and all other fragments in view pager.

But problem is this that view pager automatically generates next and previous view and when i swipe to next view it does not hide those layouts but other Fragments other than its consecutive ones Layouts are Gone.

How do i refresh consecutive fragments of view pager from fragment itself.

Thanx in advance.

2

2 Answers

0
votes

You should have an activity that control that ViewPager and detects what Fragments to display. That's the place to update the fragments.

Use the OnPageChangeListener listener and inform the fragment of the change.

If you want to do it from the Fragment itself, try onStart() or onResume()

0
votes

Fragments can be notified of events, so they can take actions accordingly.

One way of doing this would be using a broadcast like in ViewPager Activity to notify a Fragment of a specific event

Other way is like @Antonio said, making it on the OnPageChangeListener (I suppose that would be a lot cleaner).