FragmentPagerAdapter notifyDataSetChanged not working

前端 未结 6 576
天涯浪人
天涯浪人 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条回答
  •  Happy的楠姐
    2021-01-31 15:59

    What Nik Myers is saying is correct. However there is a piece missing. When notifyDataSetChanged is called, the method getItemPosition is called. You need to override this to get the fragments to reload.

     @Override
        public int getItemPosition(Object object) {
            // Causes adapter to reload all Fragments when
            // notifyDataSetChanged is called
            return POSITION_NONE;
        }
    

提交回复
热议问题