2013-09-21 30 views
3

我需要爲FragmentTabHost添加一個按鈕。如何構建這樣的東西?如何添加按鈕到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? 

回答

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>