Android EditText 输入监听使用场景系列

需求:注册界面输入手机号时候以188 8888 8888形式呈现
感谢博主:https://blog.csdn.net/as_csdn

实现效果:


手机输入.gif

实现EditText的TextWatcher接口即可,具体在深入研究

 et_phone.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                DLog.d("---------- beforeTextChanged ----------" + "\n");
                DLog.d("s: " + s + "\n");
                DLog.d("start: " + start + "\n");
                DLog.d("count: " + count + "\n");
                DLog.d("after: " + after + "\n");
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                DLog.d("---------- onTextChanged ----------" + "\n");
                DLog.d("s: " + s + "\n");
                DLog.d("start: " + start + "\n");
                DLog.d("before: " + before + "\n");
                DLog.d("count: " + count + "\n");

                if (s==null||s.length()==0){
                    return;
                }
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i 

后期在更新 相关.....

你可能感兴趣的:(Android EditText 输入监听使用场景系列)