@@ -93,6 +93,39 @@ public ActionBarContextView(Context context, AttributeSet attrs, int defStyle) {
9393 a .recycle ();
9494 }
9595
96+ @ Override
97+ public void setSplitActionBar (boolean split ) {
98+ if (mSplitActionBar != split ) {
99+ if (mActionMenuPresenter != null ) {
100+ // Mode is already active; move everything over and adjust the menu itself.
101+ final LayoutParams layoutParams = new LayoutParams (LayoutParams .WRAP_CONTENT ,
102+ LayoutParams .MATCH_PARENT );
103+ if (!split ) {
104+ mMenuView = (ActionMenuView ) mActionMenuPresenter .getMenuView (this );
105+ mMenuView .setBackgroundDrawable (null );
106+ final ViewGroup oldParent = (ViewGroup ) mMenuView .getParent ();
107+ if (oldParent != null ) oldParent .removeView (mMenuView );
108+ addView (mMenuView , layoutParams );
109+ } else {
110+ // Allow full screen width in split mode.
111+ mActionMenuPresenter .setWidthLimit (
112+ getContext ().getResources ().getDisplayMetrics ().widthPixels , true );
113+ // No limit to the item count; use whatever will fit.
114+ mActionMenuPresenter .setItemLimit (Integer .MAX_VALUE );
115+ // Span the whole width
116+ layoutParams .width = LayoutParams .MATCH_PARENT ;
117+ layoutParams .height = mContentHeight ;
118+ mMenuView = (ActionMenuView ) mActionMenuPresenter .getMenuView (this );
119+ mMenuView .setBackgroundDrawable (mSplitBackground );
120+ final ViewGroup oldParent = (ViewGroup ) mMenuView .getParent ();
121+ if (oldParent != null ) oldParent .removeView (mMenuView );
122+ mSplitView .addView (mMenuView , layoutParams );
123+ }
124+ }
125+ super .setSplitActionBar (split );
126+ }
127+ }
128+
96129 public void setContentHeight (int height ) {
97130 mContentHeight = height ;
98131 }
@@ -179,7 +212,7 @@ public void onClick(View v) {
179212
180213 final LayoutParams layoutParams = new LayoutParams (LayoutParams .WRAP_CONTENT ,
181214 LayoutParams .MATCH_PARENT );
182- if (mSplitView == null ) {
215+ if (! mSplitActionBar ) {
183216 menu .addMenuPresenter (mActionMenuPresenter );
184217 mMenuView = (ActionMenuView ) mActionMenuPresenter .getMenuView (this );
185218 mMenuView .setBackgroundDrawable (null );
0 commit comments