JingYeoh / FragmentRigger

:boom:A powerful library powered by AOP to manage Fragments.(一个基于AOP设计的Fragment管理框架)
MIT License
2.26k stars 266 forks source link

Caused by: java.lang.IllegalStateException: Can't change container ID of fragment DeviceListFragment{add691 id=0x7f090046 DeviceListFragment__dd4118ec}: was 2131296326 now 2131296455 #56

Closed WUSIR-ShiYan closed 6 years ago

WUSIR-ShiYan commented 6 years ago

我在代码中的使用: @Override protected void init(Bundle savedInstanceState) { DeviceListFragment devices = DeviceListFragment.newInstance(); Rigger.getRigger(this).addFragment(R.id.container_devices, devices); Rigger.getRigger(this).showFragment(Rigger.getRigger(devices).getFragmentTAG());

    Rigger.getRigger(this.getActivity()).addFragment(R.id.main, devices);

} 我是想把这个fragment 也放到MainActivity的Rigger里面。 最底下那行报错,报错见标题,是我的用法不对吗?

JingYeoh commented 6 years ago
@override
Rigger.getRigger(this).addFragment(R.id.container_devices, devices);
Rigger.getRigger(this.getActivity()).addFragment(R.id.main, devices);

devices 添加了两次,另外 Fragment 的操纵建议保存 tag ,并作出数据的保存。具体可以参考 ShowFragmentinit 方法和对于 savedInstanceState 的处理