Search code examples
androidandroid-actionbarspinneractionmode

Can I add spinners to ActionBar or ActionMode in android?


1.Since in API 21 the method setNavigationMode(ActionBar.NAVIGATION_MODE_LIST) is deprecated.Which API replace it?

2.Can I set the spinner right-aligned?


Solution

  • Yes you obama.

    Action bar mainly contains four functional areas. They are app icon, view control, action buttons and action overflow.

    App Icon – App branding logo or icon will be displayed here.

    View Control – A dedicated space to display app title. Also provides option to switch between views by adding spinner or tabbed navigation.

    Action Buttons – Some important actions of the app can be added here. Action Overflow – All unimportant action will be shown as a menu.

    Check out the following diagram for complete overview about action bar.

    enter image description here

    With the API 21 the method setNavigationMode(ActionBar.NAVIGATION_MODE_LIST) is deprecated.

    The best way to work with a spinner is to use a Toolbar like this:

    <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar_actionbar"
            android:layout_height="?attr/actionBarSize"
            android:layout_width="match_parent"
            android:background="?attr/colorPrimary">
    
        <Spinner
                android:id="@+id/spinner_toolbar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
    

    You can find an example in the Google IO 2014