EditTex隐藏、可编辑等状态
来源:互联网 发布:java string默认编码 编辑:程序博客网 时间:2024/06/08 15:06
1、在OnCreat()方法中写下面代码
隐藏输入框
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
有可编辑键盘
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
2、有时1的方法可能会失效,需要用的下面的方法
//软键盘隐藏
InputMethodManager im = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(getCurrentFocus().getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
3、当方法1、2不能满足需求的时候
//动态隐藏阮键盘
public static void hideSoftInput(Activity activity){
View view = activity.getWindow().peekDecorView();
if(view != null){
InputMethodManager inputmanager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputmanager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
public static void hideSoftInput(Context context,EditText edit){
edit.clearFocus();
InputMethodManager inputmanager = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputmanager.hideSoftInputFromWindow(edit.getWindowToken(), 0);
}
// 动态显示软键盘
public static void showSoftInput(Context context,EditText edit){
edit.setFocusable(true);
edit.setFocusableInTouchMode(true);
edit.requestFocus();
InputMethodManager inputManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(edit, 0);
}
4、
// 点击空白区域 自动隐藏软键盘
public boolean onTouchEvent(MotionEvent event) {
if (null != this.getCurrentFocus()) {
InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
return mInputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
}
return super.onTouchEvent(event);
}
- EditTex隐藏、可编辑等状态
- div可编辑状态设置
- jquery表单可编辑状态
- 不同类型的可编辑状态
- android 如何实现EditText从不可编辑状态变成可变成可编辑状态
- EditTex实现密码的显示隐藏
- 将WebBrower置为可编辑状态
- UITableView可编辑状态常用操作
- 设置ALV单元格可编辑状态
- UITableView可编辑状态常用操作
- UITableView可编辑状态常用操作
- UITableView可编辑状态常用操作
- UITableView可编辑状态常用操作
- 将WebBrower置为可编辑状态
- Android EditText控件切换可编辑状态
- UITableView可编辑状态常用操作
- 将iframe设置为可编辑状态
- 动态设置EditText的可编辑状态
- dedecms修改default目录办法
- Type interface com.binarysoft.service.region.RegionDAO is not known to the MapperRegistry.
- AllegroGraph Virtual Machine 安装教程
- Oracle 程序控制结构
- xgboost ppt(4)--总结
- EditTex隐藏、可编辑等状态
- UE4学习6 Collision设置
- #学志#vue入门02
- oracle中动态SQL的使用
- ORA-01031:权限不足的问题
- mvn 编译出Caused by: java.lang.UnsupportedClassVersionError: com/cainiao/maven/plugins异常
- php模式设计之单例模式
- PHP怎么做采集文章的代码
- Android SDK 无法更新