Expected the adapter to be 'fresh' while restoring state

前端 未结 7 2439
一个人的身影
一个人的身影 2021-02-20 10:24

I have a viewpager2 with multiple fragments in FragmentStateAdapter. Whenever I try to open a new fragment and then go back to my current one with viewpager2, I get an exception

7条回答
  •  悲&欢浪女
    2021-02-20 10:57

    I solved this problem by testing if it is equal null

    if(recyclerView.adapter == null) {recyclerView.adapter = myAdapter}
    

提交回复
热议问题