onCreateOptionsMenu未在选项卡滑动上调用

时间:2014-06-04 10:52:03

标签: android android-layout android-fragments tabs android-actionbar

操作栏菜单未更改,

onCreateOptionsMenu未在滑动或标签上调用

我有3个标签, 在每个标签中我管理stackfragements,

mTabsAdapter.addTab(mTabHost.newTabSpec("TabA").setIndicator(null, getResources().getDrawable(R.drawable.ic_action_feed)),ATabFragment.class, null);
mTabsAdapter.addTab(mTabHost.newTabSpec("TabB").setIndicator(null, getResources().getDrawable(R.drawable.ic_action_explor)),BTabFragment.class, null);
mTabsAdapter.addTab(mTabHost.newTabSpec("TabC").setIndicator(null, getResources().getDrawable(R.drawable.ic_action_favorit)),CTabFragment.class, null);

每个标签都会膨胀像

这样的uniq xml

`

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:padding="4dip"
    android:gravity="center_horizontal"
    android:layout_width="match_parent" android:layout_height="match_parent">
    <FrameLayout
            android:id="@+id/A_container"
            android:layout_width="match_parent"
            android:layout_height="0px"
            android:layout_weight="1">
    </FrameLayout>
</LinearLayout>

`

并在片段中创建第一个堆叠项目

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    // Inflate the layout for this fragment

    View view = inflater.inflate(R.layout.A_tab_fragemt_stack,
            container, false);

    if (savedInstanceState == null) {
        // Do first time initialization -- add initial fragment.
        Fragment newFragment = AFragment.newInstance();

        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.add(R.id.A_container, newFragment).commit();
    }

    return view;

}

0 个答案:

没有答案