0
疯狂......无论我尝试什么,我的AutoCompleteTextView
都会显示带有默认样式的下拉项目。我似乎无法访问任何方式下拉观点 - 我已经试过在XML造型,以及在我的适配器编码它以及编码了AutoCompleteTextView本身。忽略AutoCompleteTextView下拉风格
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"
/>
我的客户(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);
最后,在我的适配器,这是工作完美的样式下拉项的任何微调,但未能风格下拉为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;
}
我怎样才能改变在AutoCompleteTextView下拉列表,从而下拉文本项目以任何方式在任何风格的?
HOLA引用所需的布局,我遇到了完全一样的问题,因为你:(你说的意思是“在其构造能收到理想的布局需要我的适配器类。” ?我可以看到你的代码,或者你可以在你的答案中添加你的代码吗? – Konayuki 2016-03-31 03:13:17