嗨在我的应用程序中有一个列表视图和一个搜索部分。我需要做的是当我在搜索部分搜索一个单词时,它应该根据我搜索的单词列出相应的列表视图。排序的名字,但我真正的问题代码,如果我需要寻找比如我需要搜索在我们的应用程序在Android搜索列表?
Ramz超级
这是一个单一的名字在我当前的代码,我需要一个字搜索从R然后A等按正确的顺序排序的名称。但我需要的是,如果我开始搜索超级我需要显示n AME Ramz在listview.how超级我能做到这一点我现在的搜索代码如下所示
search_sort.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
// Abstract Method of TextWatcher Interface.
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// Abstract Method of TextWatcher Interface.
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
textlength = search_sort.getText().length();
array_sort.clear();
contactnumber_sort.clear();
for (int i = 0; i < contactname.size(); i++) {
if (textlength <= contactname.get(i).length()) {
if (search_sort.getText()
.toString()
.equalsIgnoreCase(
(String) contactname.get(i).subSequence(
0, textlength))) {
array_sort.add(contactname.get(i));
contactnumber_sort.add(contactnumber.get(i));
}
}
}
System.out.println(array_sort);
myadp = new myAdapter(MobiMailActivity.this, array_sort, contactnumber_sort);
contactlist.setAdapter(myadp);
}
});
看一看这个http://stackoverflow.com/questions/11823720 – Braj 2012-08-09 08:57:05