Bir AutoCompleteTextView öğesine 2 TextView açılır menüsünü ayarlamak için herhangi bir basit yol var mı?Bir AutoCompleteTextView'a özel bir adaptör nasıl eklenir
android.R.layout.two_line_list_item
var Hangi örnek nasıl bulacağımı bulamadınız.
Yani, bu çalıştı:
public class TwoLineDropdownAdapter extends BaseAdapter {
private LayoutInflater mInflater = null;
private Activity activity;
public ArrayList<TwoLineDropDown> values = new ArrayList<TwoLineDropDown>();
public TwoLineDropdownAdapter(Activity a, ArrayList<TwoLineDropDown> items) {
values = items;
activity = a;
mInflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
return values.size();
}
public TwoLineDropDown getItem(int position) {
return values.get(position);
}
public long getItemId(int position) {
return position;
}
public static class ViewHolder {
public TextView title;
public TextView description;
}
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.dropdown_text_twoline,
parent, false);
holder.title = (TextView) convertView
.findViewById(R.id.text1);
holder.description = (TextView) convertView
.findViewById(R.id.text2);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
return convertView;
}
public void add(TwoLineDropDown ei) {
values.add(ei);
}
}
Ama burada bir sorunla karşı karşıya:
: diyor Adaptör ayarlarken
TwoLineDropdownAdapter AutoCompleteAdapter = new TwoLineDropdownAdapter(this, items); myAutoComplete.setAdapter(AutoCompleteAdapter);
Yanlış bağlı eşleşme: AutoCompleteTextView türünde genel yöntem setAdapter (T), (TwoLineDropdownAdapter) bağımsız değişkenleri için geçerli değildir. türetilmiş tip TwoLineDropdownAdapter Bu nasıl çözmek için sınırlı parametre
geçerli bir değişiklik değil mi?
belgelerine göre You
Bu yöntemi uyguladı, ancak otomatik tamamlama görüntülenmiyor. – tony9099
"ListAdapter & Filterable" eklentisini BaseAdapter'a genişletebilir misiniz? Ben şunu söyleyebilirim: adaptöre adaptör mü? – delive
@delive, "ListAdapter" öğesini istediğiniz alt sınıfla değiştirebilirsiniz. – njzk2