我正在創建導航抽屜。片段Android
當我更換它的任何片段,它內容替換,但框架佈局在後面跑..
所以,當我按在該片段空白屏幕,主要佈局的內容顯示。那麼如何在一些片段替換它時完全移除主佈局?
android.support.v4.app.FragmentManager fm=getSupportFragmentManager();
if (id == R.id.nav_categories)
{
Categories cat=new Categories();
FragmentTransaction transaction=fm.beginTransaction().replace(R.id.relative_layout,cat);
transaction.addToBackStack(null);
transaction.commit();
/* fm.beginTransaction().replace(R.id.relative_layout,cat).commit();
Toast.makeText(this,"Categories",Toast.LENGTH_LONG).show();*/
}
else if (id == R.id.nav_rating)
{
Fragment_Rating rat=new Fragment_Rating();
fm.beginTransaction().replace(R.id.relative_layout,rat).commit();
Toast.makeText(this,"Rating",Toast.LENGTH_LONG).show();
FragmentTransaction transaction=fm.beginTransaction().replace(R.id.relative_layout,rat);
transaction.addToBackStack(null);
transaction.commit();
}
我試圖消除addtobackstack ...
可能重複[Android的 - 如何更改導航抽屜中的碎片](https://stackoverflow.com/questions/24006181/android-how-to-change-fragments-in-the-navigation-drawer) – Thecave3
爲父佈局設置背景 – MathaN