Reputation: 6444
Madness...no matter WHAT I try, my AutoCompleteTextView
shows drop down items with default styling. I cannot seem to access the dropdown view in any way - I've tried styling in XML as well as coding it up in my Adapter as well as coding up the AutoCompleteTextView itself.
spinner_dropdown_item.xml:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000"
android:textSize="16dp"
/>
My client (LoginFragment.java
):
AutoCompleteTextView user_name = (AutoCompleteTextView) layout.findViewById(R.id.user_name);
final MyAdapter<User> adapter = new MyAdapter<User>(my_activity, my_list);
//does nothing
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
//crashes app with no error or anything!
user_name.setDropDownBackgroundResource(R.layout.spinner_dropdown_item);
user_name.setAdapter(user_adapter);
Finally, in my adapter, which is working perfectly to style drop down items for any spinner, but fails to style the drop down for AutoCompleteTextView:
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
TextView tv;
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(context);
tv = (TextView) inflater.inflate(R.layout.spinner_dropdown_item, null);
} else {
tv = (TextView) convertView;
}
T object = objects.get(position);
String label = NULL_ITEM;
if (object != null) {
label = object.toString();
}
tv.setText(label);
return tv;
}
How can I change the drop down list in an AutoCompleteTextView such that the dropdown text items are styled in any way at all?
Upvotes: 2
Views: 1335
Reputation: 6444
I seem to have located the problem. My Adapter class needed to receive the desired layout in its constructor. No IDEA why it couldn't reference the desired layout in the adapter itself
Upvotes: 1