简体   繁体   English

如何在Android webview中完全禁用所有输入的软键盘

[英]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);

    • If you choose this way, be sure to return the settings to normal if that's not done automatically. 如果选择这种方式,请确保将设置恢复为正常,如果没有自动完成。 I haven't used this before and couldn't tell you how it behaves, but keep that in mind! 我之前没有使用它,也无法告诉你它是如何表现的,但请记住这一点! You don't want a user to reply to a text they receive while using your app only to have their keyboard disabled :) 您不希望用户在使用您的应用时仅回复他们收到的文本以禁用其键盘:)


  • 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扩展的自定义视图并使用它。


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

相关问题 SAPUI5 - 当焦点设置在输入字段上时,如何在 android 上禁用软键盘 - SAPUI5 - How to disable soft keyboard on android when focus is set on input field 如何禁用 Android 键盘控制 webview 中的输入字段? - How to disable the Android keyboard from taking the control over input fields in webview? 如何完全从JavaScript禁用键盘快捷键 - How to disable keyboard shortcuts completely from JavaScript 如何隐藏软键盘并保持输入焦点 - How to hide soft keyboard and keep input on focus 当软键盘在显示时重叠时,如何在Android中自动滚动到输入字段? - How to auto-scroll to input field in Android when the soft keyboard overlaps them on showing? 如何通过在Android Web View Phonegap构建中按软键盘中的Enter进入下一个输入 - How to go to next input by pressing enter in soft keyboard in android web-view phonegap build 在特定输入字段上禁用Android / iOS键盘 - Disable Android/iOS Keyboard on specific Input Fields Android App软键盘覆盖嵌入在webview中的网页textarea - Android App soft keyboard covers web page's textarea embedded in webview 用 JavaScript 隐藏软键盘后确定正确的 Android WebView 屏幕尺寸? - Determining the correct Android WebView screen size after soft keyboard hides with JavaScript? 在iOS / Android上关闭软键盘 - Close soft keyboard on iOS / Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM