首页 > 其他 > 详细

EditText判断用户输入完成,然后进行操作解决方案

时间:2016-01-14 20:45:53      阅读:299      评论:0      收藏:0      [点我收藏+]
private Timer timer = new Timer();
private final long DELAY = 1000; // in ms
EditText editTextStop = (EditText) findViewById(R.id.editTextStopId);
    editTextStop.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
        }
        @Override
        public void onTextChanged(final CharSequence s, int start, int before,
                int count) {
            if(timer != null)
                timer.cancel();
        }
        @Override
        public void afterTextChanged(final Editable s) {
            //avoid triggering event when text is too short
            if (s.length() >= 1) {              

                timer = new Timer();
                timer.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        // TODO: do what you need here (refresh list)
                        // you will probably need to use
                        // runOnUiThread(Runnable action) for some specific
                        // actions
                     
                    }

                }, DELAY);
            }
        }
    });

EditText判断用户输入完成,然后进行操作解决方案

原文:http://www.cnblogs.com/shuijilove/p/5131486.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!