In OnCreate() Method add addTextChangedListener(new TextWatcher() to an EditText View
example:
searchEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) { }
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
System.out.println("in Add text change Listner afterText change "+s);
searchLocation(s.toString());
}
});
Use Custom adapter to Set the ListView. By using on listview.setAdapter(adapter);
Create a Function for search list:
public void searchLocation(String search)
{
SEARCH_DATA.clear();
int c=0;
for(int i=0;i
SEARCH_DATA.add(holder);
System.out.println("Name searched ::"+SEARCH_DATA.get(c).getName());
c++;
//favArray[i]=DATA.get(i).name+" "+DATA.get(i).number;
}
}
adapter.notifyDataSetChanged();
//adapter.notifyDataSetInvalidated();
//setupLocationListView.invalidate();
}
0 Comment(s)