To do this, you need to create your own adapter class, then you can set a text view for it.
autoAdapter = new AutoAdapter(this, R.layout.autocompletelistview_test1, edittext);
Here is autocompletelistview_test1
<?xml version="1.0" encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="44dip" android:gravity="center_vertical" android:singleLine="true" android:ellipsize="end" android:layout_marginRight="12dip" android:textStyle="bold" android:textColor="#cc3333" android:id="@+id/textview" android:textSize="14sp" />
use the following code to change the background color of the dropdown menu e.g.
autocomplete.setDropDownBackgroundResource(R.color.autocompletet_background_color);
and you can set a value like this in string.xml
<color name="autocompletet_background_color">#EFEFEF</color>
If you want to change the text color of the drop-down element, follow these steps:
in the adapter class.
@Override public View getView(int position, View v, ViewGroup parent) { View mView = v ; if(mView == null){ LayoutInflater vi = (LayoutInflater)appContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mView = vi.inflate(id, null); } TextView text = (TextView) mView.findViewById(R.id.textview); if(getItem(position) != null ) { text.setTypeface(faceBold); if(getItem(position).equals("check some condition if you want. ")) { text.setTextColor(Color.parseColor("#999999")); text.setText("set some text"); } else { text.setTextColor(Color.parseColor("#cc3333")); text.setText(getItem(position)); } } return mView; }
Let me know if you have any questions.
source share