1)TabNavigation用法
1声明一个类继承自SherlockActivity并且实现ActionBar.TabListener接口(注意是使用actionbarsherlock中的类)
2创建Tab键
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);
}
3实现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) {
}
2)TabNavigationCollapsed用法
1继承TabNavigation
2在onCreate设置Tab的属性
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);