我想知道如果可以,请在选择时自定义AutoCompleteTextView
下拉列表的颜色。我可以自定义一切,但不是所选的颜色,即 - 它保持不变。如何在Android上自定义AutoCompleteTextView下拉菜单
在Activity
:
ArrayAdapter<String> adap = new ArrayAdapter<String>(this, R.layout.row, strings);
autoNewBird = (AutoCompleteTextView)findViewById(R.id.autoCompleteBirdName);
autoNewBird.setAdapter(adap);
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"/>
和绘制custom_spinner.xml(在绘制文件夹)
<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>
这适用于一个微调下拉,但对于AutoCompleteTextView
,选中后,它不会像更改颜色一样微调下拉。
任何帮助,或经验与此将不胜感激。
这是正确的解决方案。为了进一步说明,第二行应该像这样定义样式:。希望有帮助:) – Sandra 2013-06-25 09:22:13
你使用哪种布局来布局?我这样做aAdapterAutoComplete = new ArrayAdapter(getActivity()。getApplicationContext(),R.layout.auto_complete_text,suggest); \t \t \t \t \t autoComplete.setAdapter(aAdapterAutoComplete); –
user1163234
2014-04-28 14:58:47