findViewById()
works fine when you need to find something any UI element that is in your layout. However, using the second option of this answer How to add a Dropdown item on the action bar, I added a Spinner
to my ActionBar
.
Now the problem I am facing is how to retrieve a reference to this Spinner
so that I can change the font that it uses. How do I do that?
My menu/sort_spinner looks like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/sort"
android:showAsAction="always"
android:title="@string/sort"
android:actionLayout="@layout/actionbar_spinner"/>
</menu>
and layout/actionbar_spinner like this:
<Spinner xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:spinnerMode="dropdown"
android:id="@+id/spinner"
android:entries="@array/type" />