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:

Any ideas or something we can try?

+3


source to share


2 answers


I figured out the problem. In the child fragment, we have used getSupportFragmentManager instead of getChildFragmentManager. After replacing it, it works fine.



+1


source


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



myTextView.setText(Html.fromHtml("your html text"));

      

0


source







All Articles