如何向FragmentTabHost添加按钮

时间:2013-09-21 20:26:31

标签: android android-fragments fragment-tab-host

我需要在FragmentTabHost添加一个按钮。如何构建这样的东西?

FragmentTabHost

FragmentTabHost tabHost = (FragmentTabHost) view.findViewById(R.id.tab_host);

tabHost.setup(getActivity(), getActivity().getSupportFragmentManager(),
        R.id.tab_content);

tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("TAB 1"),
        MatchStatisticsFragment.class, null);

tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("TAB 2"),
        EventsListFragment.class, null); 
// can I add right-align button there? 

1 个答案:

答案 0 :(得分:2)

菜单按钮,仅显示图标

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/new_game"
          android:icon="@drawable/icon"
          android:title="@string/title"
          android:showAsAction="always"/>
</menu>