开发者

How to filter text in alert dialog box?

开发者 https://www.devze.com 2023-03-11 18:45 出处:网络
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.ca

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

精彩评论

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