Vote count:
0
Actually this is my main problem, I've got a NavigationDrawer and I was changing lot of things about it, because I've added a TabHostFragment inside of it, the problem is when I'm in one Fragment, I've an ActionBar icon that goes to another Fragment, but at the time to do this it works perfect, but when I go to another Fragment it still on the back of the new Fragment, I tried to put a BackGround color of each Fragment and it isn't visible. The problem is that the transaction is OK but when I'm in the other Fragment when I press in a BlankSpace (For example) and on the old Fragment has a button here with a Toast it still showing this Toast on the new Fragment.
Here are a little examples of what happens maybe with images you can understand better my question :
This main problem comes when I go trought this Fragment (I call it on MainActivity, that has no sense because I want to call it when I'm on a specific Fragment, but it's in the only part that I can call this Fragment...
This is the MainActivity where I call this FragmentTransaction :
case R.id.newOffer:
android.app.FragmentManager fm = getFragmentManager();
android.app.FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.frame_container, new TipusNouProducte());
ft.commit();
return true;
And by the way I leave you here the code from my NavigationDrawer that always when I'm going throught a Fragment it says "Error on creating Fragment"
private void displayView(int position) {
mDrawerList.setItemChecked(position, true);
mDrawerList.setSelection(position);
setTitle(navMenuTitles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
Fragment fragment = null;
switch (position) {
case 0:
fragment = new TabHostFragment();
break;
case 1:
fragment = new LocalizacionFragment();
break;
case 2:
fragment = new ListaProductosFragment();
break;
case 3:
fragment = new ConfiguracionFragment(this);
break;
case 4:
fragment = new AyudaSugerenciasFragment();
break;
case 5:
fragment = new AyudaSugerencias();
break;
case 6:
finish();
break;
default:
break;
}
if (fragment != null) {
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.frame_container, fragment).commit();
// update selected item and title, then close the drawer
mDrawerList.setItemChecked(position, true);
mDrawerList.setSelection(position);
setTitle(navMenuTitles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
} else {
// error in creating fragment
Log.e("MainActivity", "Error in creating fragment");
}
}
If you need more code that you think that can cause this problem feel free to ask to me then I'll update ASAP.
Fragment duplicates when I go to another Fragment
Aucun commentaire:
Enregistrer un commentaire