为什么构造函数ArrayAdapter(new View.OnKeyListener(){},int,String [])在编写时未定义.此编码用于在键入字数超过3个字符时从SQLite获取数据.但是,它显示以下错误.
The constructor ArrayAdapter(new View.OnKeyListener(){}, int,
String[]) is undefined
ed1 = (AutoCompleteTextView)findViewById(R.id.searchWord);
ed1.setOnKeyListener(new View.OnKeyListener()
{
Integer count = 0;
String typeWord = "";
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if (KeyEvent.ACTION_DOWN == event.getAction()) {
if (keyCode != 67) {
count++;
char c = (char)event.getUnicodeChar();
typeWord = typeWord + c;
}
else {
count--;
}
if (count > 2 && typeWord != "") {
countries = getAutosuggestWord(typeWord);
ArrayAdapter adapter = new ArrayAdapter(this, R.layout.autosuggest, countries);
ed1.setAdapter(adapter);
}
}
return false;
}
});