4 回答

TA貢獻1836條經驗 獲得超3個贊
getFragmentManger()
.beginTransaction
.replace(R.id.frame,Yourfragment.newInstance(),null)
.addtobackstack
.commit();
人們總是說我是一線客,所以這是您的一線客解決方案

TA貢獻1852條經驗 獲得超1個贊
將一個片段替換為另一個片段,并在后堆棧中保留先前的狀態:
// Create new fragment and transaction
Fragment newFragment = new ExampleFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
// Replace whatever is in the fragment_container view with this fragment,
// and add the transaction to the back stack
transaction.replace(R.id.fragment_container, newFragment);
transaction.addToBackStack(null);
// Commit the transaction
transaction.commit();
- 4 回答
- 0 關注
- 535 瀏覽
添加回答
舉報