FragmentPagerAdapter notifyDataSetChanged not working

前端 未结 6 476
天涯浪人
天涯浪人 2021-01-31 15:30

I got a FragmentPagerAdapter. It\'s getItem method can return a fragment according to data it has from the outside. After I update the data its suppose to display I

6条回答
  •  囚心锁ツ
    2021-01-31 15:59

    none of the solutions given above works for me. So hope below solution may be helpful for you.

    In my code, I have 2 Fragments in viewPager. One is used for 3 EditTexts and 1 button and another fragment has RecyclerView. On button click, my value is going to recyclerView, but it's not updating. So now, I used the below code:

    I called the notifyDataSetChanged() on button click. My MainActivity has inner adapter class extends FragmentStatePagerAdapter class. So i called it using mainActivity.mMainAdapter.notifyDataSetChanged(). Hope it helps someone.

提交回复
热议问题