android - Android - 电子邮件 InputField 不接受用户输入
问题描述
我有一个WebView
加载远程网页(这个),其 HTML 不在我的控制范围内。在该页面上,有一个电子邮件字段是必需的,并且可能具有电子邮件验证。
当我点击该电子邮件字段输入电子邮件地址时,Android 的键盘会出现,但当我开始输入时,它不会在其中写入任何内容。还有一些其他字段,它们也是必需的,并且可能已经过验证,但它们可以很好地输入。只有电子邮件字段会导致此问题。
该电子邮件字段在 Android Firefox 和 Google Chrome 中运行良好。
我的 Javascript 已启用,WebView
但它什么也没做。有谁知道我怎样才能让那个电子邮件字段接受输入?
解决方案
您的键盘不支持WebView
. 所以你需要强制WebView
打开默认键盘。
您必须WebView
通过扩展WebView
类进行自定义。覆盖其onCreateInputConnection()
方法:
import android.content.Context
import android.util.AttributeSet
import android.view.inputmethod.BaseInputConnection
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputConnection
import android.webkit.WebView
class QWebView : WebView
{
constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, privateBrowsing: Boolean) : super(context, attrs, defStyleAttr, privateBrowsing)
override fun onCreateInputConnection(outAttrs: EditorInfo?): InputConnection
{
return BaseInputConnection(this, false)
}
}
推荐阅读
- kubernetes - 告诉 Terraform 在更新 null_resource 时不要销毁和创建
- python - Moto mock_s3 EndpointConnectionError,连接被拒绝
- java - 如何在android应用程序的数据库中显示地图中的纬度和经度
- c# - Xamarin Android RecyclerView 以相反方向显示图像
- python - 在同一图上为 Dataframe 一次绘制所有行
- python - 如何从模块中导入类而不导入整个模块
- if-statement - 我应该如何在 Web 程序集中实现“else if”?
- react-native - 如何在反应原生文本输入中自动粘贴在 SMS 中收到的一次性代码
- typescript - 为什么调试器会在 /***/ }) 上中断,
- python - 如何访问在 python 的另一个文件中声明的变量?(不是面向对象)