简体   繁体   English

对本机应用程序永久响应本机android隐藏或禁用键盘

[英]react native android hide or disable keyboard permanently for kiosk app

I need to disable or hide the keyboard in my app which is a kiosk mode app. 我需要在我的信息亭模式应用程序中禁用或隐藏键盘。 I googled it and did not find way to hide keyboard for the whole app without losing focus of the input (since I will be using external keyboard). 我在Google上进行了搜索,但没有找到在不失去输入焦点的情况下为整个应用程序隐藏键盘的方法(因为我将使用外部键盘)。

I also want to have the ability to show the keyboard for maintenance by clicking on button or something. 我还希望能够通过单击按钮或其他内容来显示键盘以进行维护。

Any one who can help me here ? 有人可以在这里帮助我吗?

in your manifest file under your activity use: 在清单文件下的活动中使用:

<activity ... android:windowSoftInputMode="stateHidden">

and then in your oncreate event create an ontouchlistener : 然后在您的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;
}

}); });

and to re-enable the keyboard just add this to the item of the xml you want to enable : 并重新启用键盘,只需将其添加到要启用的xml项中即可:

android:textIsSelectable="true"

Hope that helps.. 希望有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM