且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

FragmentStateAdapter 在notifyDataSetChanged 后不重新创建currentFragment

更新时间:2023-01-22 14:52:22

我不得不重写以下两个方法...

I had to override the following two methods...

override fun getItemId(position: Int): Long {
    return items[position].id
}

override fun containsItem(itemId: Long): Boolean = items.any { it.id == itemId }

...让它发挥作用!