Can't get the Android 4.0 Split Action Bar working
Asked Answered
B

3

6

I've followed the development pages on the android dev site, but I cannot get my action bar to split to the top and bottom of the screen.

I've got a menu xml defined with a couple of options:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:id="@+id/stop_services"
    android:icon="@drawable/ic_launcher"
    android:title="@string/stop" 
    android:showAsAction="ifRoom|withText"/>
  <item android:id="@+id/start_services"
    android:icon="@drawable/pushpin"
    android:title="@string/start" 
    android:showAsAction="ifRoom|withText"/>
</menu>

In my manifest I've set the uiOption to:

<activity
  android:label="@string/app_name"
  android:name=".ProxilenceHome" 
  uiOptions="splitActionBarWhenNarrow" >

I load the menu items in the activity as follows:

public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.home_menu, menu);
    return true;
}

But when testing the application, the action bar never splits. Does anyone know the problem/ if I've missed anything out?

Thanks a lot.

Bute answered 7/12, 2011 at 13:39 Comment(4)
Are you running the app on an ICS device or emulator?Galvanoscope
Currently on device. Will try emulator too.Bute
Okay tried on the emulator, doesn't work there either.Bute
any difference if you use android:uiOptions="splitActionBarWhenNarrow"Zita
Z
25

Using android:uiOptions="splitActionBarWhenNarrow" works for me.

Without the "android:" it does not work

Zita answered 7/12, 2011 at 15:36 Comment(1)
Brilliant, thought it might have been something simple I missed out. Thanks.Bute
C
0

using this in landscape mode navigation tabs split but in portrait mode it is not work.

    final ActionBar bar = this.getActionBar();
        bar.setDisplayHomeAsUpEnabled(false);
bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
        bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);




mTabsAdapter = new TabsAdapter(this, mViewPager);
    Tab tab1=mTabsAdapter.addTab(bar.newTab().setText("DemoGraphics"),ListFragmentDemo.PatientFragment.class, null);

public boolean onCreateOptionsMenu(Menu menu)
    {

        MenuInflater inflater=getMenuInflater();
        inflater.inflate(R.menu.mainmenu, menu);
        super.onCreateOptionsMenu(menu); 

        return true;
    }

mainmenu.xml

    <menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/menu_dCollection"
         android:icon="@drawable/overflowmenu"
         android:showAsAction="ifRoom|withText"
    >
     <menu>
     <item android:id="@+id/menu_demo"

           android:title="DemoGraphics" />
     <item android:id="@+id/menu_visits"  
           android:title="Visits" />
     <item android:id="@+id/menu_vitals"  
           android:title="Vitals" />
     </menu>
    </item>
     <item android:id="@+id/add" android:showAsAction="ifRoom" android:title="Add" android:icon="@drawable/ic_action_open"></item>
     <item android:id="@+id/previous" android:showAsAction="ifRoom" android:title="Back" android:icon="@drawable/back"></item>
        <item android:id="@+id/nextFragment" android:showAsAction="ifRoom" android:title="Next" android:icon="@drawable/next"></item>
     <item android:id="@+id/menu_search" android:showAsAction="ifRoom" android:title="Search" android:actionViewClass="android.widget.SearchView" android:icon="@drawable/search" />
 </menu>

in manifest.xml file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:installLocation="preferExternal"
    package="savy.exam.actionbartabspager"
    android:versionCode="1"
    android:versionName="1.0"
    android:uiOptions="splitActionBarWhenNarrow"
     >
Cubicle answered 30/5, 2012 at 4:34 Comment(1)
sorry .i got my error.actually i create manually device configuration for emulator for that it is not working.but when i am using existing deivce configuration it`s workingCubicle
M
0

Try to add this line in your menu xml:

<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res-auto" >

Then in your item element:

myapp:showAsAction="always|withText"

It helped me.

Mello answered 11/10, 2013 at 8:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.