多个Fragment实现跳转数据不变

来源:互联网 发布:蚁群算法原理怎么改进 编辑:程序博客网 时间:2024/06/06 04:23
public void switchContent(Fragment from, Fragment to,FragmentTransaction transaction) {if (!to.isAdded()) { // 先判断是否被add过transaction.hide(from).add(R.id.framelayout_id, to).commit(); // 隐藏当前的fragment,add下一个到Activity中} else {transaction.hide(from).show(to).commit(); // 隐藏当前的fragment,显示下一个}}

0 0