Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
234 views
in Technique[技术] by (71.8m points)

android - How to control ActionBar split programmatically?

The android ActionBar may split into a top and bottom bars if activity's parameter "uiOptions" is set to "splitActionBarWhenNarrow", note this parameter is only valid in ICS.

Honeycomb has introduced a new approach to multi-select list items using action bar. When a item is under press & hold the list becomes into a multi-selection mode and the actionbar bar may be used to accomplish some actions. The actionbar setup is inherited from the list activity, i.e., if the activity has a split action bar the multi-selection will have too, and if the activity has only the top bar, so, the multi-selection will be compliant with that.

The question is, is it possible to have only a top action bar in the activity and when the list turns into multi-selection mode programmatically split the actionbar?

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

No, you cannot switch between split and non-split action bars on the fly.

The setter counterpart to android:uiOptions is on Window, not Activity. Window#setUiOptions is the method and the flag to use is ActivityInfo#UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW.

However this isn't going to do what you want. Split action bar when narrow must be specified as the window is first configured before the window decor is initialized. In other words, once the window has been displayed (or even once you've called setContentView) it's too late to change it.

This was a conscious decision by the Android UX team. Action modes (including selection modes) are meant to mirror the configuration of the action bar on the current activity. This gives the user a single place to look for currently valid actions within the same activity.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...