(转)Android开发:在EditText中封锁软键盘

(转)Android开发:在EditText中关闭软键盘?editText(EditText)findViewById(R.id.txtBody)editText.setOn

(转)Android开发:在EditText中关闭软键盘
?(转)Android开发:在EditText中封锁软键盘(转)Android开发:在EditText中封锁软键盘

    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)时阻止输入法弹出?
    ?(转)Android开发:在EditText中封锁软键盘(转)Android开发:在EditText中封锁软键盘
      InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);

      1.调用显示系统默认的输入法

      方法一、
      ?(转)Android开发:在EditText中封锁软键盘(转)Android开发:在EditText中封锁软键盘
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);imm.showSoftInput(m_receiverView(接受软键盘输入的视图(View)),InputMethodManager.SHOW_FORCED(提供当前操作的标记,SHOW_FORCED表示强制显示));


        方法二、
        ?(转)Android开发:在EditText中封锁软键盘(转)Android开发:在EditText中封锁软键盘
          InputMethodManager m=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); (这个方法可以实现输入法在窗口上切换显示,如果输入法在窗口上已经显示,则隐藏,如果隐藏,则显示输入法到窗口上)


          2.调用隐藏系统默认的输入法
          ?(转)Android开发:在EditText中封锁软键盘(转)Android开发:在EditText中封锁软键盘
            ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(WidgetSearchActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); (WidgetSearchActivity是当前的Activity)


            3.获取输入法打开的状态
            ?(转)Android开发:在EditText中封锁软键盘(转)Android开发:在EditText中封锁软键盘
              InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);boolean isOpen=imm.isActive();isOpen若返回true,则表示输入法打开



              原文:http://sunxin1001.iteye.com/blog/854182
              http://getcn.net/index.php?mod=skill&action=detail&id=43978


              另外
              参数 ??????????? 含义
              WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN
              软键盘直接覆盖Activity,通常这是默认值
              WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
              Activity高度会变化,让出软键盘的空间。和WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN 为2选1的值
              WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE
              Activity一打开就直接显示软键盘窗口,如果该窗口需要的话(即有EditText,或有ditable的控件)
              WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
              Activity打开后并不直接显示软键盘窗口,直到用户自己touch文本框。