I have created a dialogbox which shows a list of countries ,i need to create the filter such that when i pr开发者_运维问答ess a letter it should give all the items with the letter that i have typed.can you tell me way by which i can do this?
Sounds like you want a auto complete, read up on how to build this right here
You can use a TextWatcher for that by implementing its methods like this:
EditText et = (EditText) findViewById(R.id.edit_text);
TextWatcher textWatcher = new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
//... your logic
}
@Override
public void afterTextChanged(Editable arg0) {
// ... your logic
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// ... your logic
}
};
et.addTextChangedListener(textWatcher);
精彩评论