gpt4 book ai didi

android - 检测文本框点击 webview 弹出键盘

转载 作者:行者123 更新时间:2023-11-29 01:23:26 24 4
gpt4 key购买 nike

如何检测 webview 中的文本框点击?我想在用户单击 web View 中的文本框时弹出键盘。我在代码中调用 displayKeyboard() 时在代码中定义了我的键盘将显示它,但我如何触发该调用?

最佳答案

你可以这样做:

Button yourButton = new Button(context);
yourButton.setOnClickListener(this);

webView.addJavascriptInterface(yourButton,"injectedObject");

@Override
public void onClick(View v) {
//displayKeyboard()
}

HTML 按钮将如下所示:

<input type="submit" name="submit" id="some_id" onclick="yourButton.performClick();" />

你也可以阅读它addJavascriptInterface

由于您对网页没有任何控制权,您可能需要阅读以下内容:

HitTestResult

webview detuct html tag how android

请注意,您可能需要为此进行搜索:

     int type = result.getType();

if (type == WebView.HitTestResult.EDIT_TEXT_TYPE) {
return;
}

关于android - 检测文本框点击 webview 弹出键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35421491/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com