I want to make an intelligent search as in mobile contact search in android.
e.g: When the user starts input in search box, after typing one alphabet, as a result, it should display all the data starting from the alphabet that was input.
EditText searchTo = (EditText)findViewById(R.id.medittext);
searchTo.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
//here you check for your conditions...
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
doSomething();
}
});
You have two options
use AutoCompleteTextView
use textwatcher for EditText