3

I have the next scenario

An activity with a FrameLayout. In the FrameLayout I load 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 fragments contains a ViewPager and a SlidingTabLayout (Copied from https://github.com/codepath/android_guides/wiki/Google-Play-Style-Tabs-using-SlidingTabLayout)

Inside the ViewPager I'm loading as pages other fragments, each fragment is a WebView that load a local content from assets. The adapter extends FragmentPagerAdapter

When I first load this fragment everything works fine, and I can swipe and load all the pages. But If I load other fragment and I came back to load the fragment with the ViewPager again, I get random blank pages, sometimes is the first one, sometime others. Sometimes also when I swipe back the previous blank page appears, but not always

I have tried, with no luck:

  1. Check if its a WebView problem. It is not, using instead of the fragments with the webviews blank default fragments with simply a textview, I get the random blank pages too.
  2. Invalidate the views, the pager... after each scroll or page changed
  3. This approach ViewPager PagerAdapter not updating the View
  4. Set http://developer.android.com/reference/android/support/v4/view/ViewPager.html#setOffscreenPageLimit%28int%29 to load all the pages

Any ideas or something that we can try?

Community
  • 1
  • 1
dce
  • 263
  • 1
  • 2
  • 8

2 Answers2

1

I figured out the problem. At the child fragment we were using getSupportFragmentManager instead of getChildFragmentManager. After replacing it it works ok.

dce
  • 263
  • 1
  • 2
  • 8
0

Webview has rendering issue it takes time to load you can use textView with

myTextView.setText(Html.fromHtml("your html text"));
Rahul
  • 479
  • 3
  • 18
  • As I wrote I think is not a webview problem. Besides of that, I dont think load webcontent in a textview is a good idea. – dce Apr 21 '15 at 14:05