antonyt / InfiniteViewPager

Augment Android's ViewPager with wrap-around functionality.
MIT License
695 stars 194 forks source link

onCreateOptionsMenu not called in child fragment when using FragmentPagerAdapter #20

Closed Enmankan closed 9 years ago

Enmankan commented 9 years ago

That's because setPrimaryItem() is not forwarded to set adapter instance. To make it work, add the method below to InfinitePagerAdapter class:

@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
    adapter.setPrimaryItem(container, position, object);
}

Inside setPrimaryItem() FragmentPagerAdapter calls setMenuVisibility() on fragments to ensure only one would get menu callbacks. Without calling setPrimaryItem() all fragments have menu visibility set to false by default.

antonyt commented 9 years ago

Thanks for noticing this - I added this a few days ago: https://github.com/antonyt/InfiniteViewPager/commit/e1d7b36ebcf2b9ca59bbbac3112ac99bb32f7e97