嗨,我实现了 MultiAutocompleteTextview 我有两个 senerios 一个是显示列表第二个是数据库中已经存在的数据要设置到适配器。
但它不起作用任何人都可以帮助我
provisional_diagnosisadapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, Pre_Conditions);
provisional_diagnosisadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
pre_existing.setAdapter(provisional_diagnosisadapter);
pre_existing.setThreshold(1);
pre_existing.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
ArrayAdapter<String> adapter=(ArrayAdapter<String>)pre_existing.getAdapter();
if(isallergerys.equals("true")) {
int position1 = adapter.getPosition(pre_condition);
provisional_diagnosisadapter.notifyDataSetChanged();
pre_existing.setSelection(position1);
}
else {
int position1 = adapter.getPosition(preExistingCondition_dropdownList1.getCondition());
provisional_diagnosisadapter.notifyDataSetChanged();
pre_existing.setSelection(position1 + 1);
}
pre_existing.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if(position+1>0) {
PreExistingCondition_DropdownList preExistingCondition_dropdownList1 = preExistingCondition_dropdownLists.get(position);
preconid = preExistingCondition_dropdownList1.getId();
precontname = preExistingCondition_dropdownList1.getCondition();
}
}
});
}