如何让Activity启动时EditText自动弹出软键盘?
- 内容介绍
- 文章标签
- 相关推荐
本文共计120个文字,预计阅读时间需要1分钟。
在Manifest.xml文件中,针对相应的activity,添加以下代码来启动EditText并自动弹出软键盘:xml
Activity启动edittext自动弹出软键盘解决办法1在Manifest.xml文件中相应的activity下添加一下代码android:wiActivity启动edittext自动弹出软键盘解决办法
1在Manifest.xml文件中相应的activity下添加一下代码
android:windowSoftInputMode"stateHidden"
2EditText始终不弹出软键盘
EditText edit(EditText)findViewById(R.id.edit); edit.setInputType(InputType.TYPE_NULL);
3在onCreate方法中加入以下代码使不弹出软件键盘
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
4
InputMethodManager im (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(homepageLayout.getWindowToken(), 0);
——homepageLayout为当前视图
5)
//去虚拟输入栏
InputMethodManager imm (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
转:blog.51cto.com/jishuren/1621411
本文共计120个文字,预计阅读时间需要1分钟。
在Manifest.xml文件中,针对相应的activity,添加以下代码来启动EditText并自动弹出软键盘:xml
Activity启动edittext自动弹出软键盘解决办法1在Manifest.xml文件中相应的activity下添加一下代码android:wiActivity启动edittext自动弹出软键盘解决办法
1在Manifest.xml文件中相应的activity下添加一下代码
android:windowSoftInputMode"stateHidden"
2EditText始终不弹出软键盘
EditText edit(EditText)findViewById(R.id.edit); edit.setInputType(InputType.TYPE_NULL);
3在onCreate方法中加入以下代码使不弹出软件键盘
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
4
InputMethodManager im (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(homepageLayout.getWindowToken(), 0);
——homepageLayout为当前视图
5)
//去虚拟输入栏
InputMethodManager imm (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
转:blog.51cto.com/jishuren/1621411

