发布于 2017-09-26 01:35:39 | 165 次阅读 | 评论: 0 | 来源: 网友投递
Android移动端操作系统
Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。
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;
}
}
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!