リストビューとそのアダプターをグローバル変数として保存しています。を拡張してリストを作成していませんListActivity
。私のコードは次のとおりです。
public void onCreate(Bundle...) {
mListView = (ListView) findViewById(R.id.listview1);
//setting my custom array adapter...works fine.
//also my custom adapter implements Filterable interface
mListView.setAdapter(...)
mListView.setTextFilterEnabled(true);
//My edit text where I enter my query
mSearchEditText = (EditText) findViewById(R.id.searchEditText);
mSearchEditText.addTextChangedLIstener(myListener);
}
private TextWatcher myListener = new TextWatcher () {
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s == null || s.length() == 0) {
mListView.clearTextFilter();
}
else {
mListView.setFilterText(s.toString());
}
}
...
...
}
私の問題は、編集テキストに文字列を入力すると、リスト内の使用可能な検索項目 (番号のみ) が正しく表示されますが、項目自体は表示されないことです。
たとえば、リストに項目aa、bb、cc、dd、ff、ee、ee がある場合
したがって、 ee を検索すると、結果はee, ee ではなくaa, bbになります。ccを検索すると、フィルタ リストにはaaのみが表示されます。
誰でもこれについて私を助けることができますか?