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 关注
- 512 浏览
添加回答
举报