的EditText TextChangeListener问题 [英] EditText TextChangeListener issue

查看:268
本文介绍了的EditText TextChangeListener问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的意思用于搜索目的的编辑文本。我已经加入

I have an edit text meant for searching purpose. I have added

searchET.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // TODO Auto-generated method stub              
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count,
                    int after) {
                // TODO Auto-generated method stub              
            }

            @Override
            public void afterTextChanged(Editable s) {
                // TODO Auto-generated method stub
                //intent to another page where i show my search result
            }
        });

的问题是:
当我给了如搜索字符串:堡垒我得到所需的结果在接下来的页面。但是,当我preSS后退按钮,它不移动到previous页面上的第一次点击。我将不得不preSS后退按钮4次转到了previous页面。这是因为我的搜索字符串是长度为4的和每一个值被输入到所述的EditText时,textchangelistener被调用。我怎样才能解决这个问题呢?请回复。先谢谢了。

The problem is: When I give a search string for eg: "fort" i get the required result in the next page. But when I press the back button, it doesnt move to the previous page on its first click. I will have to press back button 4 times to goto the previous page. This is because my search string is of length 4 and each time a value is entered into the edittext, the textchangelistener is called. How can I solve this issue? Please reply. Thanks in advance.

推荐答案

根据你需要什么,你可以去根据某些条件下一个页面。例如,启动一个计时器,如果 afterTextChanged 是计时器到期之前调用,复位定时器。或者,你可以有一个按钮,搜索,用户明确地表示他做键入单词。

Depending on what you need, you can go to the next page based on some condition. For example, start a timer, and if the afterTextChanged is called before the timer expires, reset the timer. Alternatively, you can have a button 'Search' where the user explicitly indicates that he's done typing the word.

如果您可以共享所需的行为,更好的替代品,可以建议。

If you can share the required behaviour, better alternatives can be suggested.

这篇关于的EditText TextChangeListener问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆