Search List In Our Application In Android?
Hi in my app there is a list view and a search section.what i need to do is when i search a word in the search section it should sort out the corresponding list view according to t
Solution 1:
Try to use contains()
instead of equalsIgnoreCase()
.Where datasetList
is object of my custom ArrayList<ContactList>
.
publicvoidonTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
String getSearchString = search.getText().toString();
if(datasetList != null && datasetList.size() > 0)
{
sortedList = new ArrayList<ContactDataSet>(); //new List sorted list for (int i = 0; i < datasetList.size(); i++) {
if (datasetList.get(i).getName().contains(getSearchString)) {
sortedList.add(datasetList.get(i));
}
}
}
adapter.setnewList(sortedList);
lView.setAdapter(adapter);
}
Try this and let me know.It is working for me.Hope this helps you
Post a Comment for "Search List In Our Application In Android?"