ActionBar actionBar = getActionBar();
actionBar.setTitle( "1407勇士");
// 设置小箭头
// 默认true 如果是true,显示小箭头,能点击
actionBar.setDisplayHomeAsUpEnabled( true );
// 默认true,如果是false 隐藏图标和title
// actionBar.setDisplayShowHomeEnabled(true);
// 设置排列方式(导航方式) 设置横向排列
actionBar. setNavigationMode(ActionBar. NAVIGATION_MODE_LIST);
final String[] strArray = new String[] { "华山派", "古墓派" , "峨眉派" };
// 准备数据适配器
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this ,
android.R.layout. simple_list_item_1 , android.R.id.text1 ,
strArray);
actionBar. setListNavigationCallbacks(arrayAdapter, new OnNavigationListener() {
@Override
public boolean onNavigationItemSelected( int itemPosition, long itemId) {
// TODO Auto-generated method stub
return false;
}
}) ;
/*TabListener listener=new TabListener() {
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
tab.getText().toString().trim();
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
};
actionBar.addTab(actionBar.newTab().setText("蛋黄派")
.setIcon(R.drawable.ic_launcher).setTabListener(listener));
actionBar.addTab(actionBar.newTab().setText("勇士派")
.setIcon(R.drawable.ic_launcher).setTabListener(listener));
actionBar.addTab(actionBar.newTab().setText("冻栋派")
.setIcon(R.drawable.ic_launcher).setTabListener(listener));*/