您的位置:首页 > 移动开发 > Android开发

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

2014-08-12 17:29 615 查看
点击按钮 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);
}
}
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐