本文整理汇总了Java中android.app.ActionBar.setNavigationMode方法的典型用法代码示例。如果您正苦于以下问题:Java ActionBar.setNavigationMode方法的具体用法?Java ActionBar.setNavigationMode怎么用?Java ActionBar.setNavigationMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.ActionBar
的用法示例。
在下文中一共展示了ActionBar.setNavigationMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClick
import android.app.ActionBar; //导入方法依赖的package包/类
public void onClick(View v) {
final ActionBar bar = getActionBar();
int flags = 0;
switch (v.getId()) {
case R.id.toggle_home_as_up:
flags = ActionBar.DISPLAY_HOME_AS_UP;
break;
case R.id.toggle_show_home:
flags = ActionBar.DISPLAY_SHOW_HOME;
break;
case R.id.toggle_use_logo:
flags = ActionBar.DISPLAY_USE_LOGO;
break;
case R.id.toggle_show_title:
flags = ActionBar.DISPLAY_SHOW_TITLE;
break;
case R.id.toggle_show_custom:
flags = ActionBar.DISPLAY_SHOW_CUSTOM;
break;
case R.id.toggle_navigation:
bar.setNavigationMode(
bar.getNavigationMode() == ActionBar.NAVIGATION_MODE_STANDARD
? ActionBar.NAVIGATION_MODE_TABS
: ActionBar.NAVIGATION_MODE_STANDARD);
return;
case R.id.cycle_custom_gravity:
ActionBar.LayoutParams lp = (ActionBar.LayoutParams) mCustomView.getLayoutParams();
int newGravity = 0;
switch (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
case Gravity.LEFT:
newGravity = Gravity.CENTER_HORIZONTAL;
break;
case Gravity.CENTER_HORIZONTAL:
newGravity = Gravity.RIGHT;
break;
case Gravity.RIGHT:
newGravity = Gravity.LEFT;
break;
}
lp.gravity = lp.gravity & ~Gravity.HORIZONTAL_GRAVITY_MASK | newGravity;
bar.setCustomView(mCustomView, lp);
return;
}
int change = bar.getDisplayOptions() ^ flags;
bar.setDisplayOptions(change, flags);
}
示例2: onCreate
import android.app.ActionBar; //导入方法依赖的package包/类
/**
* @brief This is the onCreate method
* @param savedInstanceState
* @details The onCreate method adds an actionBar to the activity with two tabs (recent and favorites).
* It also load the preferences file into the prefs attribute and sets the rememeberExit attribute.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab_host);
final ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE|ActionBar.DISPLAY_SHOW_HOME);
final String recents = getString(R.string.recents);
final String favorites = getString(R.string.favoritesTab);
// add tabs
Tab tab1 = actionBar.newTab()
.setText(recents)
.setTabListener(new TabListener<ListFragmentTab>(
this, "tab1", ListFragmentTab.class));
actionBar.addTab(tab1);
Tab tab2 = actionBar.newTab()
.setText(favorites)
.setTabListener(new TabListener<ListFragmentTabFav>(
this, "tab2", ListFragmentTabFav.class));
actionBar.addTab(tab2);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
//accedemos a fichero preferencias
(Configuration.getInstance()).setPrefs( getSharedPreferences("PreferencesFile",Context.MODE_PRIVATE));
(Configuration.getInstance()).readPrefs();
// Orientation Change Occurred
if(savedInstanceState!=null){
int currentTabIndex = savedInstanceState.getInt("tab_index");
actionBar.setSelectedNavigationItem(currentTabIndex);
}
//nombre en la activity bar
final String title = getString(R.string.connections);
setTitle(title);
}