android - 为 kiosk 应用程序永久响应本机 android 隐藏或禁用键盘
问题描述
我需要在我的信息亭模式应用程序中禁用或隐藏键盘。我用谷歌搜索它并没有找到隐藏整个应用程序的键盘而不失去输入焦点的方法(因为我将使用外部键盘)。
我还希望能够通过单击按钮或其他东西来显示键盘以进行维护。
有谁能在这里帮助我吗?
解决方案
在您的活动下的清单文件中使用:
<activity ... android:windowSoftInputMode="stateHidden">
然后在您的 oncreate 事件中创建一个 ontouchlistener :
MyEdittext.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View MyView, MotionEvent event) {
MyView.onTouchEvent(event);
InputMethodManager inputMethod = (InputMethodManager)MyView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethod!= null) {
inputMethod.hideSoftInputFromWindow(MyView.getWindowToken(), 0);
}
return true;
}
});
要重新启用键盘,只需将其添加到要启用的 xml 项目中:
android:textIsSelectable="true"
希望有帮助..
推荐阅读
- ios - 如何将 SpriteKit Sprite 节点的可点击区域从矩形更改为圆形?
- javascript - 使用 TeaVM 将 java 库移植到 wasm
- javascript - 使用 javascript 检查段落中的 ClassName 是否等于按钮中的 TextContent
- snowflake-cloud-data-platform - 无法取消查询
- scala - 在 scala 中,是否可以阻止编译器首先搜索 Predef 隐式?
- javascript - 如何将数字数组转换为仅在单击加号图标时出现的列表?
- python - 计算 pandas 文本列中最常见的短语
- python - 如何将数据帧转换为 0 和 1 的 ndarray?
- sql - 在 postgresql 中匹配客户 ID 值
- sql - IF 在 SAP HANA 中的时间间隔