Hi, there is a list view and a search section in my application. What I need to do, when I search for a word in the search section, it should sort the corresponding list according to the word I found. code to sort the name, but my real problem is that I need to search for a word, for example, I need to search
Ramz super
which is the only name in my current code, I need to search, like from R, then A, etc. in the correct order to sort the name. But I need me to start the search from Super I need to show the name Ramz super in listview. How can I do this, my current search code is shown below
search_sort.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
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);
}
});
source