77.android 简单的EditText自动弹起软键盘

//第一步在布局里给EditText设置:

android:focusable="true"
android:focusableInTouchMode="true"

//第二步在Activity代码里:

//在Activity启动后会自动将焦点定位到第一个EditText并且键盘自动弹起。
et_phonenum.setFocusable(true);
et_phonenum.requestFocus();
InputMethodManager imm = (InputMethodManager) et_phonenum.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);

//你要弹起什么软键盘就在布局设置 什么样的属性,比如要弹出数字键盘就在布局写:

android:phoneNumber="true"

//------------------------------------------------------------------------完-------------------------------------------------------------------------------

猜你喜欢

转载自blog.csdn.net/weixin_42061754/article/details/83000386