Android EditText重新获取焦点弹出软键盘,选中内容

来源:互联网 发布:流星网络电视tv版apk 编辑:程序博客网 时间:2024/05/01 15:55
点击按钮 EditText重新获取焦点:弹出软键盘
                etPatientAllergy.setEnabled(true);                etPatientAllergy.setFocusable(true);                etPatientAllergy.setFocusableInTouchMode(true);                etPatientAllergy.requestFocus();                etPatientAllergy.requestFocusFromTouch();                etPatientAllergy.selectAll();                InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);                imm.showSoftInput(etPatientAllergy, InputMethodManager.RESULT_SHOWN);                imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
Android 对话框AlertDialog中显示了一个输入框 ,EditText自动获得焦点,自动显示软件键盘。
final AlertDialog dialog= new AlertDialog.Builder(mContext).create();editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {   @Override   public void onFocusChange(View v, boolean hasFocus) {       if (hasFocus) {            dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);       }   }});


0 0
原创粉丝点击