1
我正在使用AutoCompleteTextView。在這裏,我只想顯示以鍵入的字母開頭的名稱,因爲它顯示了包含我輸入的這個字母的所有單詞。AutoCompleteTextView選擇以字母開頭的單詞
fi_nameArray = new ArrayList<String>();
fi_nameArray = mDbHelper.getFIName(a,m);
ArrayAdapter<String> fi_adapter = new ArrayAdapter<String>(this,
android.R.layout.select_dialog_item, fi_nameArray);
fiName.setThreshold(1);
fiName.setAdapter(fi_adapter);
fiName.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
ma_fiName = fiName.getText().toString();
}
});
發表您的查詢從mDbHelper .. –
你需要實現'ArrayAdapter'自定義過濾器。看看[這](http://stackoverflow.com/questions/16782288/autocompletetextview-with-custom-adapter-and-filter) –