@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
if(tab.getPosition()==0)
{
FragmentA frag = new FragmentA();
ft.replace(android.R.id.content, frag);
}
else
{
FragmentB frag = new FragmentB();
ft.replace(android.R.id.content, frag);
}
}
The above code loads in fragments, the problem is it creates a new instance of each fragment, so going to and from tabs, the fragment reloads. What is the best way to make it so it does not create a new instance of each fragment eahc time and only uses the origial instance?
Thanks
Use an attribute in your class