I am using FragmentStatePagerAdapter
for listing my Fragmets
in ViewPager
. Every fragment contains just a WebView
. Everything works fine, I just want to use the preload mechanism of PagerAdapter
which loads 1 Fragment
in advance. This is the simplified code for my Fragment
:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.ecard_fragment, container, false);
webview = (WebView) view;
webview.loadDataWithBaseURL("", HTML, "text/html", "utf-8", "");
Toast.makeText(getActivity(), "fragment: " + NAME, Toast.LENGTH_SHORT).show();
return view;
}
I'm sure, that the next Fragment
is pregenerated, because Toast
is shown in advance. But the WebView
is loaded later - just after Fragment
is focused. How to force the WebView
to load?