本文介绍了设置splitActionBarWhenNarrow从Java在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能告诉机器人只拆分动作条时,我想它,但在相同的活动。我的使用情况是,默认情况下,对吧我的动作都OK都要塌了,但在一个长按一个项目,我进入编辑任务模式,操作栏是用来提供一些速记到编辑任务。我想这个编辑模式来使用拆分操作栏,因为它有图标的是更好可见向右走,并保持不拆操作栏的普遍看法 - 它只是设置等等。

I'm wondering if it would be possible to tell android to split the ActionBar only when I want it to, but on the same Activity. My use case is that by default, the actions I have on the bar are OK to be collapsed, but on a long click on an item, I enter an "Edit Task" mode, where the action bar is used to provide some shorthands to edit a task. I'd like this "edit mode" to use the split action bar, as it has icon's that are better off to be visible right away, and keep the "not split" action bar for the general view - where it's just "settings" etc.

所以,问题是,我可以设置安卓uiOptions =splitActionBarWhenNarrow从code,而不是硬code它在清单?

So the question is, can I set android:uiOptions="splitActionBarWhenNarrow" from the code, instead of hardcode it in the Manifest?

PS:我使用的ActionBar福尔摩斯

PS: I'm using ActionBar Sherlock.

推荐答案

本机操作栏可以设置成拆分模式时通过调用 getWindow()。setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW)

The native action bar can be set into split mode by calling getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW).

它们设置后,所以用ActionBarSherlock必须调用 getSherlock()窗口的UI选项不能被读取。setUiOptions(...)。你不必为通话双方。 ABS会自动调用上述适当的时候。

Window UI options cannot be read after they are set so with ActionBarSherlock you have to call getSherlock().setUiOptions(...). You don't have to call both. ABS will automatically call the above when appropriate.

本的必须的被装饰视图建立之前完成。最安全的地方把这个呼吁,以确保总是发生在您的活动的onCreate 方法之前您拨打 super.onCreate

This must be done before the decor view has been created. The safest place to put this call to ensure that always happens is in your activity onCreate method before you call super.onCreate.

这篇关于设置splitActionBarWhenNarrow从Java在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 05:28