Android检测键盘显示或隐藏键盘的实现代码
Android 检测键盘是否显示及隐藏键盘的方法~~

站在用户的角度思考问题,与客户深入沟通,找到仙居网站设计与仙居网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站设计、成都网站设计、企业官网、英文网站、手机端网站、网站推广、域名注册、网页空间、企业邮箱。业务覆盖仙居地区。
Android 中对于键盘的隐藏与显示的文章很多,今天公司项目需求不仅需要键盘隐藏和显示还需要对键盘的状态进行检查,这里做一个简单的实现实例,供大家参考:
实现代码:
package com.newland.util;
import android.app.Activity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
/**
* 系统输入法键盘 检测工具
*
* @author yuyh
*
*/
public class IMEUtil {
/**
* 隐藏键盘
* @param context
*/
public static void hideIme(Activity context) {
if (context == null)
return;
final View v = context.getWindow().peekDecorView();
if (v != null && v.getWindowToken() != null) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
}
/**
* 检查系统键盘是否显示
* @param context
* @return
*/
public static boolean isSysKeyboardVisiable(Activity context) {
final View v = context.getWindow().peekDecorView();
if (v != null && v.getWindowToken() != null) {
return true;
}
return false;
}
}感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
本文题目:Android检测键盘显示或隐藏键盘的实现代码
当前网址:http://www.jxjierui.cn/article/jjishi.html


咨询
建站咨询
