Android edittext 软键盘互相抢夺焦点,onFocusChange方法会回调多次?
PHP中文网
PHP中文网 2017-04-17 17:55:22
0
3
663
protected static class BlurChangeListener implements OnFocusChangeListener {
        

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                //do something
            }
        }
    }
 

RT,怎么处理让其只是光标不在edittext上才回调?

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
洪涛

Finally, it was handled through the handler. When there is a keyboard, this method is continuously called back, so everything mentioned above has problems.

巴扎黑

Only one gets focus by default?

Peter_Zhu

Edittext does not steal focus.
Looking at your code, I guess you have set multiple Edittexts to this listener.
Then you should write it like this, like onclickListener

@Override
    public void onFocusChange(View v, boolean hasFocus) {
        if (!hasFocus) {
            if(v.getId == R.id.et_id){
                //do something
            }
        }
    }

I’ve been reading about the problem for a long time. If it has been solved long ago, I suggest you answer the question yourself and adopt it. This will be better for everyone

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template