我正在制作一个包含多个片段的 android 应用程序。我的第一个片段由一些元素和这样的视频视图组成:
当我用谷歌地图视图打开片段时,交易工作正常,但是当我回到第一个片段时,地图视图并没有像这样完全隐藏:
这两个片段分配在主片段活动中,并在必要时隐藏/显示,如下所示:
private void setFragment(Fragment fragment)
{
FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
// If Active fragment is instance of AccueilFragment I hide this one
if(activeFragment instanceof AccueilFragment)
{
System.out.println("accueil fragment hide");
trans.hide(mAccueilFragment);
}
// If Active fragment is instance of CataloguesFragment I hide this one
if(activeFragment instanceof CataloguesFragment)
{
System.out.println("ctalogue fragment hide");
trans.hide(mCataloguesFragment);
}
// If Active fragment is instance of MagasinsFragment I hide this one
if(activeFragment instanceof MagasinsFragment)
{
System.out.println("magasins fragment hide");
trans.hide(mMagasinsFragment);
}
// If Active fragment is instance of NewsFragment I hide this one
if(activeFragment instanceof NewsFragment)
{
System.out.println("news fragment hide");
trans.hide(mNewsFragment);
}
mListFragments.add(fragment);
// I set the new active fragment
activeFragment = fragment;
// I show it
trans.show(fragment);
// And I commit transaction
trans.commit();
}
谷歌地图视图似乎没有隐藏并在前台传递,有人可以帮助我吗?