I took the viewPager example from here
and its working fine with listViews.
I changed it up a bit to work with webviews.
I removed the listView methods and i changed the class to “extends Fragment” and i added a webview to the fragment layout
this is where i load the url
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
((WebView)getActivity().findViewById(R.id.webView1)).loadUrl(imgURL);
}
the methods gets called when i swipe to a new fragment but the image loads on a random fragment. It loads on one fragment and you need to swipe to other fragments until it loads on another fragment randomly but it never appears on two fragments.
I assume its because the ArrayListFragment is static so i tried to make it not static and create new objects in the getItem method but it resulted in the same behavior.
apparently getActivity() was the culprit and i solved the loading with
int the onCreateView() method.