中輸入第一個字母本身時未顯示的人建議列表在我們輸入第一個字母本身期間未顯示的用戶建議列表中。在搜索欄中輸入第二個字母后,建議將顯示。任何人都會給出此question.`可能的解決方案在我們在android
search.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
adapter.getFilter().filter(s, new Filter.FilterListener() {
public void onFilterComplete(int count) {
Log.d("log", "result count:" + count);
if (count == 0) {
usermsg.setText("No username found");
usermsg.setVisibility(View.VISIBLE);
peoplelist.setVisibility(View.GONE);
} else {
usermsg.setVisibility(View.GONE);
peoplelist.setVisibility(View.VISIBLE);
}
}
});
}
@Override
public void afterTextChanged(final Editable s) {
adapter.getFilter().filter(s, new Filter.FilterListener() {
public void onFilterComplete(int count) {
Log.d("log", "result count:" + count);
if (text.equals("people")) {
//movieList.clear();
getPeople();
if (count == 0) {
usermsg.setText("No username found");
usermsg.setVisibility(View.VISIBLE);
peoplelist.setVisibility(View.GONE);
} else {
usermsg.setVisibility(View.GONE);
peoplelist.setVisibility(View.VISIBLE);
}
} else if (text.equals("tag")) {
getTag(s);
usermsg.setText("# No Hash Tag found");
usermsg.setVisibility(View.VISIBLE);
peoplelist.setVisibility(View.GONE);
/*else {
usermsg.setVisibility(View.GONE);
peoplelist.setVisibility(View.VISIBLE);
}*/
}
}
});
}
});`
在你onTextChanged或afterTextChanged您可以執行opertion你爲什麼要執行操作的addTextChangedListener方法的兩個方法的編輯文本... –
我可以做什麼來顯示人名單,同時在編輯文本框中鍵入第一個字母 – suriya
你必須維護到arraylist ...一個是所有的數據,另一個是來自過濾器的最短數據。 ... –