开发者

How to filter text in alert dialog box?

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜