I am using ActionBarSherlock and I am trying to implement the structure of nested fragments using the viewpager.
I have an activity that contains some views and a wrapper fragment (FragmentA)
This FragmentA contains a view pager that shows FragmentA.1, FragmentA.2, FragmentA.3.
By default, onCreateOptionsMenu events are not dispatched to child fragments, as discussed here . Therefore, I use this solution to solve the problem.
It works great on API level 17, but below it does not show the parameters for the first fragment, but when I look at the others, everything starts to work fine. I tried calling onCreateOptionsMenu from the parent fragment, but did not get the result. It also works when I scroll back to the first fragment.
Any suggestions?
Update:
A clearer way to express structure:
By wrapper snippet, I meant the snippet that contains the viewpager. Thus, the structure
ACTIVITY -> WRAPPER FRAGMENT (holds viewpager and passes childfragmentmanager to adapter(FragmentPagerAdapter) as fragmentmanager) (parent is activity) -> CHILDFRAGMENTS(items of viewpager) (parent is wrapper fragment but viewpager manages its framelayout)
I also found a workaround that is not so nice:
if(Build.VERSION.SDK_INT > 17){ pager.setCurrentItem(1,false); } else { new android.os.Handler().postDelayed(new Runnable() { @Override public void run() { pager.setCurrentItem(1, true); } }, 300); }