如何行动加入到拆分的顶部动作条 [英] How to add actions to the top part of a split ActionBar

查看:172
本文介绍了如何行动加入到拆分的顶部动作条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果一个机器人动作条被分成顶部,使用 Android的底部:uiOptions =splitActionBarWhenNarrow Manifext.xml , 让他们都在底部的是有没有办法迫使一些行动,以显示在顶部呢?

If an Android ActionBar is split into a top and a bottom portion using android:uiOptions="splitActionBarWhenNarrow" in the Manifext.xml, is there a way to force some of the actions to be displayed in the top portion instead of having them all at the bottom?

推荐答案

是的!您可以继续使用机器人:uiOptions =splitActionBarWhenNarrow在你的Manifest.xml

Yes! You can continue to use android:uiOptions="splitActionBarWhenNarrow" in your Manifest.xml.

您刚才还需要设置:

// set the actionbar to use the custom view
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

//set the custom view to use
getActionBar().setCustomView(R.layout.custom_action_bar_top);

其中, R.layout.custom_action_bar_top 将有所有你希望出现在顶部操作栏上的按钮的视图。

Where R.layout.custom_action_bar_top would be a view that has all the buttons you wish to appear in the top action bar.

所有你想要的底部,应该在活动的 onCreateOptionsMenu 方法添加像往常一样,菜单项

All the menu items that you want at the bottom, should be added as usual in the onCreateOptionsMenu method of your activity.

这篇关于如何行动加入到拆分的顶部动作条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆