Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
I am doing one Android project using sqlite DB and was able to populated the lists in listview.
I was also able to search the words in listview using following codes:
Java
@Override
           public void onTextChanged(CharSequence s, int start, int before, int count) {

               MainActivity.this.myAdapter.getFilter().filter(s);
or
Java
@Override
           public boolean onQueryTextChange(String newText) {
               // myAdapter.getFilter().filter(newText );
               if (TextUtils.isEmpty(newText)) {
                   lvUsers.clearTextFilter();
               } else {
                   lvUsers.setFilterText(newText.toString());
               }
               return true;
}


but i am getting random words which is related to the entered string from listview, suppose i have words like apple, an , bool,abc, abort, boll, god , good etc. So i need to get only "bool", "boll" while i enter "b" EditText or searchview. but now i am getting bool,abc,abort and boll so on.
therefore, your kind helps are most appreciated.Thank You
Posted

1 solution

It can be done by checking the index of the typed string inside the word you get from database. Follow my solution here-
Filtering Listview according to name in android[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900