I have a problem with my android app, I'm developing with Android STUDIO IDE. Pretty much when I leave the app in the background for a few minutes, or is killed by the system or I mix the different layouts of the fragment. I have put a picture below:
I've already tried a variety of methods, if you have others write as well. Thank you in advance.
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.TabListener tl = new ActionBar.TabListener() {
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
}
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
pager.setCurrentItem(tab.getPosition());
actionBar.setSelectedNavigationItem(tab.getPosition());
}
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
}
};
String label1 = getResources().getString(R.string.label1);
ActionBar.Tab tab;
tab = actionBar.newTab();
tab.setText(label1);
tab.setIcon(R.drawable.download);
//tab.setIcon(R.drawable.data);
tab.setTabListener(tl);
actionBar.addTab(tab);
String label2 = getResources().getString(R.string.label2);
tab = actionBar.newTab();
tab.setText(label2);
tab.setIcon(R.drawable.search);
tab.setTabListener(tl);
actionBar.addTab(tab);
String label3 = getResources().getString(R.string.label3);
tab = actionBar.newTab();
tab.setText(label3);
tab.setIcon(R.drawable.television);
tab.setTabListener(tl);
actionBar.addTab(tab);
Image: