I'm using the ActionBarCompat and both Title text followed by a spinner in the ActionBar. I'm using theme Theme.AppCompat.Light.DarkActionBar which should show white text on a black background. The title text does show in white but the spinner text appear in black. Switching the theme to Theme.AppCompat.Light has both as black text on white. Can anyone suggest how I can get white text into the spinner? I've seen suggestions for ActionBar and ActionBarSherlock but can't get them to work on ActionBarCompat. I've tried styles as per the following without success:
<style name="SBRRTheme" parent="AppTheme">
<item name="android:spinnerDropDownItemStyle">@style/SBRRCustomDropDownItemStyle</item>
</style>
<style name="SBRRCustomDropDownItemStyle"> parent="@android:style/Widget.AppCompat.Light.DropDownItem.Spinner">
<item name="android:textAppearance">@style/SBRRCustomDropDownItemTextStyle</item>
</style>
<style name="SBRRCustomDropDownItemTextStyle"> parent="@android:style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:textColor">@color/white</item>
</style>
The activity definition in the manifest is:
<activity
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
android:name="com.example.actionbar2.RaceResultsActivity"
android:label="@string/action_raceresults"
android:parentActivityName=".MainActivity" >
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
Further information, after testing with a Nexus-S emulator and on a physical Galaxy S2, both running JellyBean, the problem with the spinner appearance in the ActionBarCompat itself only shows up on my development device, a Galaxy Y running 2.3.5 Gingerbread. Also shows on a 2.3.3 AVD.
You need to set listadapter as R.layout.support_simple_spinner_dropdown_item
Example:
Context context = ab.getThemedContext();
ArrayAdapter<CharSequence> listAdapter =
ArrayAdapter.createFromResource(context, R.array.locations, R.layout.support_simple_spinner_dropdown_item);
listAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
The support library has a layout for drop down spinner item.
@Kuitsi comment is correct. Use the same layout for dropdown view and item.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With