[英]How to completely disable soft keyboard for all input in Android webview
I am using phonegap to develop a web app for Android, and since I will have my own keypad in HTML, I need to disable android's system keyboard, preventing the it from showing up when the user clicks on any text input field. 我正在使用phonegap为Android开发一个Web应用程序,因为我将在HTML中拥有自己的键盘,我需要禁用android的系统键盘,防止它在用户点击任何文本输入字段时出现。 I don't want to use readonly input field or onblur()
since I would like to have the cursor in the text filed so user can move the cursor position while they're entering inputs. 我不想使用只读输入字段或onblur()
因为我希望将光标放在文本字段中,这样用户可以在输入输入时移动光标位置。
So I want to completely disable Android's keyboard on default, I tried adding android:windowSoftInputMode="stateAlwaysHidden"
to manifest.xml
but this does not work. 所以我想在默认情况下完全禁用Android键盘,我尝试将android:windowSoftInputMode="stateAlwaysHidden"
到manifest.xml
但这不起作用。
I also try use a javascript interface from here , but there was a javascript-java bridge crash issue on Android 2.3.x.( link to issue ). 我也尝试使用这里的javascript界面,但Android 2.3.x上有一个javascript-java桥崩溃问题。( 链接问题 )。 So I still don't have a good solution now. 所以我现在还没有一个好的解决方案。 Please help. 请帮忙。
Thank in advance for any help. 提前感谢您的帮助。
Okay, you've got a few options! 好的,你有几个选择! You can try to disable the keyboard completely using: 您可以尝试使用以下方法完全禁用键盘:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
You could use something similar to the following link. 您可以使用类似于以下链接的内容。 I haven't dug through it very thoroughly (tl;dr) but he creates a custom view that extends from android.inputmethodservice.KeyboardView
and uses that instead. 我没有彻底挖掘它(tl; dr)但是他创建了一个从android.inputmethodservice.KeyboardView
扩展的自定义视图并使用它。
Lastly (I'm not sure how much this would differentiate from the first one) you could create your own IME. 最后(我不确定这会与第一个区别多少)你可以创建自己的IME。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.