我在扩展 Android WebView 的类中长按文本时遇到复制粘贴问题。
我可以复制,但无法粘贴。 在调查时,网上某处得到了调查 android.webkit.WebViewClassic 的建议。
在 WebViewClassic 中,有一个名为 pasteFromClipboard() 的方法。 我认为代码的实际粘贴发生在该方法中,但不确定。
那么谁能告诉我我是对的吗,即调查 WebViewClassic 对我来说是否值得?
如果是,请告诉我 WebView 和 WebViewClassic 之间的关系是什么,即在 WebView 中点击多长时间会转到 WebViewClassic。
抱歉,我不能公开我的代码或日志。
最佳答案
WebViewClassic 是 WebView 的默认 WebViewProvider。来自实现说明:
The WebView is a thin API class that delegates its public API to a backend WebViewProvider
class instance. WebView extends {@link AbsoluteLayout} for backward compatibility reasons.
Methods are delegated to the provider implementation: all public API methods introduced in this
file are fully delegated, whereas public and protected methods from the View base classes are
only delegated where a specific need exists for them to do so.
基本上,触摸处理从 WebView 转发到 WebViewClassic 实例。如果您通读它的 onTouchEvent 实现及其内部 WebViewInputDispatcher 实现 PrivateHandler
,您可以跟踪触摸处理将导致调用 WebViewClassic 实例上的 pasteFromClipboard()
的位置。
所以是的,你是对的。当您点击 PastePopupWindow 上的粘贴按钮时,将调用 WebViewClassic 的 pasteFromClipboard();
方法。
关于android - android WebView 和 WebViewClassic 之间的关系是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19034294/