Disable hard keyboard input for EditText in Android

我只是一个虾纸丫 提交于 2019-12-02 15:32:44

问题


I'm new to android and I need to set a EditText to use soft keyboard input only. It should not display any text that I type using the hard keyboard.is this possible ?

Update: I use the hard keyboard input to track key events using onKeyDown method in Activity class and perform a separate task, problem comes when a EditText field is focused, it displays what ever the key I pressed using the hard keyboard. I need to avoid this and let only soft keyboard inputs into a particular EditText field and use the hard keyboard input to a different task.


回答1:


According to your need, you can set keyboard settings in Android Manifest File.

<uses-configuration android:reqFiveWayNav=["true" | "false"] 
            android:reqHardKeyboard=["true" | "false"]
            android:reqKeyboardType=["undefined" | "nokeys" | "qwerty" |  
                                     "twelvekey"]
            android:reqNavigation=["undefined" | "nonav" | "dpad" | 
                                   "trackball" | "wheel"]
            android:reqTouchScreen=["undefined" | "notouch" | "stylus" | 
                                    "finger"] />


来源:https://stackoverflow.com/questions/12511140/disable-hard-keyboard-input-for-edittext-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!