I have dynamically created the action bar and tabs. I have define a class for tab fragments like the below code.
public static class TabFragmentClass extends
Change your fragment to this,
public static class TabFragmentClass extends Fragment
{
private static CustomWebView webview=null;
private static boolean isInitialized=false;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
try
{
linearLayout=new LinearLayout(sActiveContext);
linearLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
linearLayout.setOrientation(LinearLayout.VERTICAL);
webview=new CustomWebView(sActiveContext);
FrameLayout layout=webview.createwebview();
onLoadWebview();
linearLayout.addView(layout);
linearLayout.setId(sActionBar.getSelectedTab().getPosition());
return linearLayout;
}
catch(Exception error)
{
System.out.println(error.getMessage());
return null;
}
}
@Override
public void onActivityCreated()
{
super.onActivityCreated();
isInitialized=true;
}
@Override
public void onResume()
{
if(isInitialized)
onLoadWebView();
}
public void onLoadWebview()
{
for (int i = 0; i < arrayList.size(); i++) {
if(sActionBar.getSelectedTab().getPosition()==i)
{
webview.initwebview(arrayList.get(i));
mWebViewList.add(i, webview);
break;
}
}
}
}
onCreateView only will be create Once ONLY after Activity Created You can put your method in onResume() or refresh web You can see the Fragment's life circle here