可编辑内容的Android webview将失去它';s焦点
我一直在尝试使用Webview实现RichTextEditor。Webview加载了内容可编辑的html。为了第一次集中注意力,我需要在webview上单击三次以上。当我们再次点击输入文本的末尾或行尾以获得焦点时,它也失去了焦点,我需要多次点击 我已经做了以下工作,以使其聚焦可编辑内容的Android webview将失去它';s焦点,android,webview,lost-focus,Android,Webview,Lost Focus,我一直在尝试使用Webview实现RichTextEditor。Webview加载了内容可编辑的html。为了第一次集中注意力,我需要在webview上单击三次以上。当我们再次点击输入文本的末尾或行尾以获得焦点时,它也失去了焦点,我需要多次点击 我已经做了以下工作,以使其聚焦 editorWebview.setFocusableInTouchMode(true); editorWebview.setFocusable(true); editorWebview.requestFocus(View.
editorWebview.setFocusableInTouchMode(true);
editorWebview.setFocusable(true);
editorWebview.requestFocus(View.FOCUS_DOWN);
当失去焦点时,在自定义Webview的onTouch中请求焦点
switch (event.getAction())
{
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_DOWN:
if (!v.hasFocus()) {
v.requestFocus();
}
break;
}
注意:
我正在运行javascript将样式应用于在webview中输入的文本
请告诉我我错过了什么
-谢谢我删除了脚本中使用的eval命令。现在我可以摆脱焦点问题。您创建了自定义WebView类并重写了onTouch方法还是只实现了onTouchListener?WebView的onTouchListener在某些API版本上不起作用。我在自定义WebView中重写了onTouch方法。我想在WebView中使用RichTextEditor。请,您可以分享您的自定义Webview类!提前谢谢