0

I've stumbled upon another tricky error...

I'm using basic ViewPager, which consists of several pages, which are basically consisted of HTML, displayed by a WebView.

I use the method:

mWebView.loadDataWithBaseURL(null, html, "text/html", "utf-8", "about:blank") 

for showing the contents. HTML is a String variable. Everything work fine, but I would expect all the views to be preloaded (I've set offscreenpage limit of the viewpager and even instantiate item is called right with the right data), but it isn't.

The webview is loaded, but displayed only after the click. It doesn't occur to me first, because I clicked everytime I wanted to show another page, but if you move to quickly, clicks get a bit delayed and no page is displayed. Only after I click again. Or, if I drag one page and move slightly right, I can see that the another view is not loaded yet... it displays only after one second.

Has anybody encountered something similar?

Any help is appreciated.

4

3 回答 3

0

我也有同样的问题,也在寻求帮助。似乎整个 ViewPager 直到点击后才显示出来,但是 requestFocus() 和 requestChildFocus() 都没有工作。有一点不同,这个问题只发生在我初始化 ViewPager 时。当我移动到另一个页面时,webview 内容显示良好。

于 2012-07-18T02:40:46.373 回答
0

我已经找到了解决方案:只需简单地使用ViewPager.setCurrentItem(position)来显示您想要的默认页面(在我的情况下通常是第一页)。

于 2012-07-19T03:32:49.233 回答
0

您需要setPageTransformer在寻呼机中删除。我有同样的问题,我修复了它。

于 2015-07-01T03:12:12.300 回答