WebViews inside ViewPager not always updating
I have the following scenario
Activity with FrameLayout. In FrameLayout, I am loading fragments using replace
android.support.v4.app.Fragment contentToLoad = null;
android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
...get the proper fragment depending of some logic
contentToLoad = new FragmentDemoContent();
fragmentTransaction.replace(R.id.fl_contentcontainer, contentToLoad);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
One of the snippets contains ViewPager and SlidingTabLayout (copied from https://github.com/codepath/android_guides/wiki/Google-Play-Style-Tabs-using-SlidingTabLayout )
Inside the ViewPager I load other fragments as pages, each fragment is a WebView that loads local content from assets. Adapter extends FragmentPagerAdapter
When I first load this snippet everything works fine and I can scroll and load all pages. But if I load another fragment and I go back to load the fragment again using the ViewPager, I get random blank pages, sometimes this is the first one, sometimes others. Sometimes also when I sit back down the previous blank page appears, but not always
I tried, no luck:
- Check if there is a problem with the WebView. This is not the case, instead of snippets with default webviews with just a textview, I get random blank pages as well.
- Invalid views, pager ... after every scroll or page change
- This ViewPager PagerAdapter approach does not update the view
- Install http://developer.android.com/reference/android/support/v4/view/ViewPager.html#setOffscreenPageLimit%28int%29 to load all pages
Any ideas or something we can try?
source to share