【发布时间】:2013-06-25 07:44:25
【问题描述】:
谁能指导我如何在使用 baseadapter 时使用搜索结果数据更新自定义列表视图。
我的代码是
public void onTextChanged(CharSequence s, int start, int before,
int count) {
String searchString = editText.getText().toString();
int textLength = searchString.length();
searchResults.clear();
for (int i = 0; i < name1.size(); i++) {
String peoplename = name1.get(i).toString();
Log.d(TAG, "onTextChanged:" + peoplename.length());
if (textLength <= peoplename.length()) {
Log.d(TAG, "people left: " + peoplename.length());
if (searchString.equalsIgnoreCase(peoplename.substring(
0, textLength))) {
searchResults.add(name1.get(i));
Log.d(TAG, "searchresult: " + searchResults);
}
任何帮助表示赞赏..谢谢
【问题讨论】:
-
在listView中搜索请参考this link
-
不,我已经可以在 listView 中搜索了。我可以在 logcat 中显示结果,但无法在列表视图中更新它
-
在 efery 搜索结果后,您必须更新基本适配器源列表。
-
你能发布一个关于如何做到这一点的sn-p吗?
标签: android listview android-listview baseadapter