我通过扩展AutoCompleteTextView(使用一个名为setCursorAdapter的专门函数)创建了一个自定义视图。我正在提供一个SimpleCursorAdapter并添加一个FilterQueryProvider。我正在使用这个列表的数字,我需要的能力搜索任何地方的号码匹配。
public void setCursorAdapter(final Uri uri, final String key) {
Cursor c = getContext().getContentResolver().query(uri,
new String[] { "_id", key }, null, null, key);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(getContext(),
android.R.layout.simple_dropdown_item_1line, c,
new String[] { key }, new int[] { android.R.id.text1 });
this.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
((SimpleCursorAdapter) getAdapter()).getFilterQueryProvider()
.runQuery(s);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,