광기 ... 아무리 시도해도 내 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의 드롭 다운 목록을 변경하여 드롭 다운 텍스트 항목의 모양이 전혀 달라지지 않게하려면 어떻게해야합니까?
안녕하세요, 나는 당신과 똑같은 문제를 겪고 있습니다. "내 어댑터 클래스는 생성자에서 원하는 레이아웃을 받아야합니다." ? 코드를 보거나 대답에 코드를 추가 할 수 있습니까? – Konayuki