I recently switched from ActionBarSherlock to the Android Support Library ActionBar, and now I get a null on the action view of a spinner in the action bar.
Here's the code as suggested by the docs:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.home_menu, menu);
MenuItem spinnerItem = menu.findItem(R.id.menuNavigateType);
View view = MenuItemCompat.getActionView(spinnerItem);// !! view is NULL !!
...
}
Here's R.menu.home_menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res-auto">
...
<item
android:id="@+id/menuNavigateType"
myapp:showAsAction="always"
myapp:actionViewClass="android.support.v7.widget.Spinner" />
...
</menu>
How do I get my action view?
Thanks.