动作条菜单项NestedFragments消失 [英] ActionBar Menu Items disappear in NestedFragments

查看:148
本文介绍了动作条菜单项NestedFragments消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Android 4.2现在支持<一href="http://developer.android.com/about/versions/android-4.2.html#NestedFragments">NestedFragment ,并将其添加到支持V13。

Since android 4.2 now support NestedFragment , and added it to support v13.

我用这个NestedFragment上一个经典情况:创建碎裂,可以刷卡左,右和消耗了大部分屏幕空间,并插入fragmentB和fragmentC到每个片段页

I use this NestedFragment on a classic situation : Create fragmentA that can swipe left and right and consume a majority of the screen space, and insert fragmentB and fragmentC into each fragment page.

我的问题是我在fragmentB和fragmentC创建菜单项不能老是在Activity`s actionbar.Which演出前我用NestedFragment,效果很好。

My Problem is the MenuItem I create in fragmentB and fragmentC can`t show on Activity`s actionbar.Which before I use NestedFragment , it works well.

推荐答案

在某些时候同样的问题了。如果你使用的是ActionBarSherlock库,这是一个小bug。什么你基本上需要做的是从你的父母片段调用从onCreateOptionsMenu()方法中的儿童onCreateOptionsMenu()方法是这样的:

got at some point the same problem. If you're using the ActionBarSherlock library this is a small bug. What you basically have to do is to call from your parent fragment from the onCreateOptionsMenu() method the onCreateOptionsMenu() method of the children, something like:

public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    getChildFragment().onCreateOptionsMenu(menu, inflater);
}

希望这个作品,让我知道。

hope this works, let me know.

干杯。

这篇关于动作条菜单项NestedFragments消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆