爲什麼構造ArrayAdapter(新View.OnKeyListener(){},整型,字符串[])在以下未定義我的編碼。此編碼用於在輸入字數超過3個字符時從SQLite獲取數據。但是,它顯示以下錯誤。爲什麼ArrayAdapter <String>構造(新View.OnKeyListener(){},整型,字符串[])是未定義
構造ArrayAdapter(新View.OnKeyListener(){},整型,字符串 [])是未定義
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<String> adapter = new ArrayAdapter<String>(this, R.layout.autosuggest, countries);
ed1.setAdapter(adapter);
}
}
return false;
}
});
哇..太棒了。你拯救了我的生命。 – ppshein