软键盘“确认”、“下一步”、“搜索”等事件监听

软键盘“确认”、“下一步”、“搜索”等事件监听

    edittext.setOnEditorActionListener(new TextView.OnEditorActionListener() {  
                  
                @Override  
                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {  
                    /*判断是否是“GO”键*/  
                    if(actionId == EditorInfo.IME_ACTION_GO){  
                        /*隐藏软键盘*/  
                        InputMethodManager imm = (InputMethodManager) v  
                                .getContext().getSystemService(  
                                        Context.INPUT_METHOD_SERVICE);  
                        if (imm.isActive()) {  
                            imm.hideSoftInputFromWindow(  
                                    v.getApplicationWindowToken(), 0);  
                        }  
                          
                        edittext.setText("success");  
                        webview.loadUrl(URL);  
                          
                        return true;  
                    }  
                    return false;  
                }  
            });  

 

posted @ 2016-08-26 10:18  听懂·动听  阅读(1313)  评论(0编辑  收藏  举报