How do popBackStack() and replace() operations differ?

后端 未结 2 609
庸人自扰
庸人自扰 2020-12-07 17:20

I\'ve encountered some curious behavior in my application when managing Fragments and I was wondering if SO could help shed some light onto why this happens.

I hav

2条回答
  •  太阳男子
    2020-12-07 17:24

    This is maybe because the fragment manager reuse the fragment instance rather recreate it. If the code inside Fragment B onCreate() requires to be executed when the fragment is shown, then move the code in another method like onResume().

提交回复
热议问题