本文介绍了在网页视图不ViewPager接收用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现与里面网页视图一个ViewPager。
该网页视图中包含的JavaScript来与用户交互。

I am implementing a ViewPager with webviews inside it.The webviews contains javascripts to interact with the user.

在第一页的工作web视图,而其他不工作。

The webview on the first page work, while the others do not work.

如果网页视图是高于屏幕,我之后滚动它向上或向下,那么它的工作原理。
我觉得它像web视图呈先保持焦点,而不是让别人来获得的事件。

If a webview is higher then the screen, after I scroll it down or up, then it works.I think it is like the webview showed firstly maintain the "focus" and not let the others to get the events.

我不能给它一个解决方案,
所有的WebView工作,如果我把他们作为第一页,但他们并不在以下页面工作。

I cannot a solution to it,all the webview work if I set them as the first page, but they do not work in the following pages.

推荐答案

好吧,很多头痛后,我发现这是同样的问题,这里显示:
Android的WebView软糖 - >不应该发生:没有基于RECT-测试节点发现

Ok, After a lot of headache, I find this is the same problem as showed here:Android WebView JellyBean -> Should not happen: no rect-based-test nodes found

我解决它通过继承的WebView和覆盖方法:

I solved it by subclassing WebView and overriding the method:

@Override
public boolean onTouchEvent(MotionEvent event) {
  if (event.getAction() == MotionEvent.ACTION_DOWN){
    webview.onScrollChanged(webview.getScrollX(), webview.getScrollY());
  }
  return super.onTouchEvent(event);
}

可能是第一个网页视图显示出正确地创建,同时其通过在背景中的viewpager创建其他的,具有用于接收所述事件的错误区域

Probably the first webview showed is correctly created while the other which are created by the viewpager in background, have a wrong area for receiving the event.

也许有更好的方法来解决这个问题,但至少现在它的作品。

Maybe there is a better way to solve it, but at least now it works.

这篇关于在网页视图不ViewPager接收用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 16:09