如何右对齐的ActionBar导航下拉? [英] How to right-align a navigation dropdown in ActionBar?
问题描述
我创建了一个新的项目,有Eclipse中创建了一些骨骼code与一个动作条的活动。我已删除了还创建默认菜单(设置图标,显示在右侧)。
问题
现在,有一个在动作条没有设置菜单,我想我的下拉菜单右对齐。
这怎么可能?
屏幕截图
code样品
公共类主要扩展FragmentActivity实现ActionBar.OnNavigationListener
{ @覆盖
保护无效的onCreate(捆绑savedInstanceState)
{
super.onCreate(savedInstanceState);
的setContentView(R.layout.main); //设置操作栏中显示的下拉列表。
最后的动作条动作条= getActionBar();
actionBar.setDisplayShowTitleEnabled(真);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); //设置操作栏中的下拉列表中导航。
actionBar.setListNavigationCallbacks(
//指定SpinnerAdapter来填充下拉列表。
新ArrayAdapter<串GT;(getActionBar()getThemedContext()。
android.R.layout.simple_list_item_1,
android.R.id.text1,新的String [] {
的getString(R.string.title_section1)
的getString(R.string.title_section2)
的getString(R.string.title_section3)}),这一点);
}@覆盖
公共布尔onCreateOptionsMenu(菜单菜单)
{
//没有设置菜单
返回false;
}
}
这是不可能从左侧移动操作栏功能的
权利。你可以,但是,加微调作为一个动作视图和自定义
这使它看起来准确和行为像微调从
操作栏列表导航。
块引用>来源: http://stackoverflow.com/a/15732152/794336
I've created a new project and had Eclipse create some skeleton code for an Activity with an ActionBar. I've removed the default menu that was also created (the "Settings" icon that shows on the right side).
Problem Now that there's no Settings menu in the ActionBar, I want my dropdown to align to the right. How is that possible ?
Screenshot
Code Sample
public class Main extends FragmentActivity implements ActionBar.OnNavigationListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Set up the action bar to show a dropdown list. final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // Set up the dropdown list navigation in the action bar. actionBar.setListNavigationCallbacks( // Specify a SpinnerAdapter to populate the dropdown list. new ArrayAdapter<String>(getActionBar().getThemedContext(), android.R.layout.simple_list_item_1, android.R.id.text1, new String[] { getString(R.string.title_section1), getString(R.string.title_section2), getString(R.string.title_section3), }), this); } @Override public boolean onCreateOptionsMenu(Menu menu) { // no settings menu return false; } }
解决方案It is impossible to move Action bar features from the left to the right. You can, however, add a Spinner as an Action View and customize it so that it looks and behaves exactly like the Spinner from the Action bar list navigation.
Source: http://stackoverflow.com/a/15732152/794336
这篇关于如何右对齐的ActionBar导航下拉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!