Search code examples
javaandroidactionbarsherlockandroid-actionbarandroid-tabs

How to set dynamic created action bar to bottom?


To create a navigation bar, I have dynamically create an action bar:

public void onCreate(Bundle savedInstanceState) {
    ActionBar actionBar = getActionBar();
}

And add tabs one by one:

    // Create first Tab
    tab = actionBar.newTab().setTabListener(new FragmentsTab1());
    // Create your own custom icon
    tab.setIcon(R.drawable.tab1_hdpi);
    actionBar.addTab(tab);

The problem is , the action bar is at the top by default. How can I placed it at the bottom? I found layout_below may be suitable for this case . However , as it generates dynamically, how can I know its ID? Thanks a lot.

Edited:

After adding split option, it doesn't make any changes, is it due to my action bar is dynamically generated?

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:uiOptions="splitActionBarWhenNarrow"
package="com.example.tabtest"
android:versionCode="1"
android:versionName="1.0" >

And

       <activity
        android:name="com.example.tabtest.MainActivity"
        android:uiOptions="splitActionBarWhenNarrow"
        android:label="@string/app_name" >

Solution

  • Add this to your activity tag in the Minifest

     uiOptions="splitActionBarWhenNarrow"