仅使用标签使用动作栏 。 < a href=" http:// actionbarsherlock.com/index.html" rel=“ no follow” > ActionBarSherlock 库可以很容易地做到这一点。 在 ActionBarsherlock 样本中通过 TabNavgation Clobdd cleveld class
public class TabNavigationCollapsed extends SherlockActivity implements ActionBar.TabListener {
private TextView mSelected;
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(SampleList.THEME); //Used for theme switching in samples
super.onCreate(savedInstanceState);
setContentView(R.layout.tab_navigation);
mSelected = (TextView)findViewById(R.id.text);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
for (int i = 1; i <= 3; i++) {
ActionBar.Tab tab = getSupportActionBar().newTab();
tab.setText("Tab " + i);
tab.setTabListener(this);
getSupportActionBar().addTab(tab);
时 时
时 时
@Override
public void onTabReselected(Tab tab, FragmentTransaction transaction) {
时 时
@Override
public void onTabSelected(Tab tab, FragmentTransaction transaction) {
mSelected.setText("Selected: " + tab.getText());
时 时
@Override
public void onTabUnselected(Tab tab, FragmentTransaction transaction) {
时 时
时 时