Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set NAVIGATION_MODE_LIST on Toolbar new appcompat v7 21

Now all methods related to navigation modes in the ActionBar class, such as setNavigationMode()... are now deprecated.

The documentation explains:

Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead.

In my current application, there is a spinner on ActionBar. How do I apply NAVIGATION_MODE_LIST on the new widget Toolbar in the new version appcompat v7 21.
Thanks in advance.

like image 263
Huy Duong Tu Avatar asked Oct 29 '14 07:10

Huy Duong Tu


1 Answers

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" />

</android.support.v7.widget.Toolbar>

You can find an example in the Google IO 2014

like image 174
Gabriele Mariotti Avatar answered Oct 11 '22 12:10

Gabriele Mariotti