`
sunxin1001
  • 浏览: 304851 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Android开发:在EditText中关闭软键盘

阅读更多

1、EditText有焦点(focusable为true)阻止输入法弹出  

editText=(EditText)findViewById(R.id.txtBody);

        editText.setOnTouchListener(new OnTouchListener() {             

            public boolean onTouch(View v, MotionEvent event) {  

                editText.setInputType(InputType.TYPE_NULL); // 关闭软键盘      

                return false;

            }

        });  

2、当EidtText无焦点(focusable=false)时阻止输入法弹出  

        InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);     

        imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);        

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics