开发者

Capturing webview clicks (not just from links)

开发者 https://www.devze.com 2023-02-16 16:44 出处:网络
Is there some way to set an onClickListener for a webview?I\'ve seen code here to intercept url clicks but I would just like to intercept anytime a user clicks the area the webview\'s on or swipes acr

Is there some way to set an onClickListener for a webview? I've seen code here to intercept url clicks but I would just like to intercept anytime a user clicks the area the webview's on or swipes across it with their finger. I load html directly into the webview (as opposed to giving it a url) for formatting reasons and I'd really like to be able to tell a开发者_运维知识库ny time the user clicks anywhere on the screen. I had been using a textview and that works fine, but is it doable with a webview?


Have you tried instead of an onClick, an onLongClick listener?

Taken from my recent project:

printMessageTextView.setOnLongClickListener(new OnLongClickListener() {
        int active = 0;
        @Override
        public boolean onLongClick(View v) {

In this case, the int active = 0; is probably not needed. But should be able to listen for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消