EditText在使用中,默认情况下是自动获取焦点的,但是有很多情况下,我们不需要它弹出显示,这时候就需要我们根据不同场景来决定焦点的获取与否

显示:EditText是默认显示的,多个editText的情况下会按照顺序进行焦点的获取  在布局文件中设置

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

    在.java文件中

EditText.setFocusable(true);EditText.setFocusableInTouchMode(true);EditText.requestFocus();

隐藏:布局文件中将其父控件设置为:

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

 在.java文件中

Parent.setFocusable(true);Parent.setFocusableInTouchMode(true);

手动控制软键盘的显示与否

软键盘隐藏代码

InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);imm.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);

软键盘显示代码:

InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); 

仅此献给有需要的人!!!

更多相关文章

  1. Android(安卓)lint 自动检测并删除无用资源
  2. Android系统权限和root权限的获取以及应用权限列表
  3. 使用Jenkins自动打包android
  4. Android与Js调用
  5. 获取listview checkbox选择的值 android
  6. Android-内存映射mmap
  7. dex 转为 jar
  8. Android(安卓)ndk移植c库libpng
  9. android的ndk开发入门示例

随机推荐

  1. Android自带的theme
  2. Android图片旋转
  3. Android(安卓)layout属性大全
  4. Android应用开发——系统自带样式Android
  5. Android中activity背景色的设置
  6. android线上包禁止抓取https包
  7. Activity-RelativeLayout
  8. Android:EditText 多行显示及所有属性
  9. android ListView 去除下划线和选中模式
  10. Android:Material Design(三) 动画