Android EditText 点击不弹出系统的输入法

来源:互联网 发布:mac版ios手游模拟器 编辑:程序博客网 时间:2024/06/04 21:53

1、首先监听setOnTouchListener按下的操作,且要在ACTION_DOWN下的情况下返回 true


ed_test = (EditText) findViewById(R.id.ed_test);


ed_test.setOnTouchListener(new OnTouchListener() {

@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
        InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        if(event.getAction() == MotionEvent.ACTION_DOWN){  
            if(getCurrentFocus()!=null && getCurrentFocus().getWindowToken()!=null){  
              manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);  
            }


            ed_test.requestFocus();//强制使其获取焦点

         }
return true;
}
});

阅读全文
0 0
原创粉丝点击