テキストの色を変更できるスピナーのカスタムレイアウトを使用します。これを行う方法のJavaの例を次に示します。
Spinner mySpinner = (Spinner)findViewById(R.id.spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.row, R.id.weekofday, new String[]{"ELEM 1","ELEM 2"}); // layoout.row is your custom layout.
mySpinner.setAdapter(adapter);
スタイルスピナー:
<?xml version="1.0" encoding="utf-8"?>
そして、そのドローアブルを背景として設定します。
<Spinner android:id="@+id/spinner_chemical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:background="@drawable/myspinner_background"/>
また、ListViewの場合、次のようにスタイルを設定できます。
<style name="ListViewCustomStyle" parent="android:Widget.ListView">
<item name="android:listSelector">@drawable/list_selector_holo_light</item>
<item name="android:fastScrollTrackDrawable">@drawable/fastscroll_thumb_holo</item>
<item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb_holo</item>
<item name="android:dividerHeight">0.5dip</item>
<item name="android:divider">#e9e9e9</item>
<item name="android:fadingEdge">none</item>
<item name="android:cacheColorHint">#00000000</item>
</style>
これが、リストビューのスタイル設定に使用されるドローアブルです。
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:drawable="@android:color/transparent" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_disabled_holo_light" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/list_selector_disabled_holo_light" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition_holo_light" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition_holo_light" />
<item android:state_focused="true" android:drawable="@drawable/list_focused_holo" />
</selector>
それで全部です。