zoukankan      html  css  js  c++  java
  • 关于 edittext 软键盘退出监听解决办法

    edittext 有个onCreateInputConnection 的方法,通过它可以自定义一个输入法连接器,那里连接器里面有个方法(finishComposingText)能监听输入完成的动作.

    public class MyEditText extends EditText{  
       
            public MyEditText(Context context) {  
                    super(context);  
            }   
            private OnFinishComposingListener mFinishComposingListener;  
               
            public void setOnFinishComposingListener(OnFinishComposingListener listener){  
                    this.mFinishComposingListener =listener;  
            }   
            @Override  
            public InputConnection onCreateInputConnection(EditorInfo outAttrs) {  
                    return new MyInputConnection(super.onCreateInputConnection(outAttrs), false);  
            }    
            public class MyInputConnection extends InputConnectionWrapper {  
                    public MyInputConnection(InputConnection target, boolean mutable) {  
                            super(target, mutable);  
                    }  
                    @Override  
                   public boolean finishComposingText() {  
                            boolean finishComposing = super.finishComposingText();  
                            if(mFinishComposingListener != null){  
                                    mFinishComposingListener.finishComposing();  
                            }  
                            return finishComposing;  
                    }  
            }     
            public interface OnFinishComposingListener{  
                    public void finishComposing();  
            }  
    }  
  • 相关阅读:
    异常处理
    添加headers头文件反爬虫
    爬百思不得姐的视频(爬多页时for的循环)
    图片爬取百思不得姐(正则的取法,下载的方法,%s的用法)
    创建一个网页
    集合幂级数总结
    题解(新)
    JOI汉堡肉
    NOIO 2020 r2 总结
    长链剖分
  • 原文地址:https://www.cnblogs.com/yiludugufei/p/4578981.html
Copyright © 2011-2022 走看看