我想知道如果可以的话,从AutoCompleteTextView
选择时自定义下拉列表的颜色.我可以自定义其他所有内容,但不能选择所选颜色,即 - 它保持不变.
在Activity
:
ArrayAdapter<String> adap = new ArrayAdapter<String>(this, R.layout.row, strings);
autoNewBird = (AutoCompleteTextView)findViewById(R.id.autoCompleteBirdName);
autoNewBird.setAdapter(adap);
Run Code Online (Sandbox Code Playgroud)
row.xml:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/birdtext"
android:padding="5dip"
android:background="@drawable/custom_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/spinner_item"
android:gravity="center_vertical"
android:layout_gravity="center_vertical" android:lines="1"/>
Run Code Online (Sandbox Code Playgroud)
和drawable custom_spinner.xml(在drawable文件夹中)
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
android:drawable="@drawable/listback" />
<item android:state_window_focused="false" android:state_enabled="false"
android:drawable="@drawable/listback" />
<item android:state_pressed="true" android:drawable="@drawable/threebythree" />
<item android:state_enabled="true" android:state_focused="true"
android:drawable="@drawable/threebythree" />
<item android:state_enabled="true" android:drawable="@drawable/listback" />
<item android:state_focused="true" android:drawable="@drawable/listback" />
<item android:drawable="@drawable/listback" />
</selector>
Run Code Online (Sandbox Code Playgroud)
这适用于微调器下拉列表,但对于AutoCompleteTextView
选中,它不会像微调器下拉列表那样改变颜色.
任何帮助,或经验与此将不胜感激.