카테고리 없음
[기계적 인조 인간] ViewPager는 업데이트 된 콘텐츠로 조각을 업데이트하지 않습니다.
필살기쓰세요
2021. 2. 8. 20:32
어떤 문제가 발생했는지 잘 모르겠지만 FragmentPagerAdapter를 FragmentStatePagerAdapter (MainAdapter로 확장)로 대체하여 한 번 시도해 볼 수 있습니다.
-------------------문제가 무엇인지 정확히 이해하지 못합니다. 잘못된 구현의 결과 일 수 있습니다. 그러나 시도했지만 favouriteAdapter.notifyDataSetChanged();
여전히 새로 고쳐지지 않으면.
보기를 제거하고 새로 고친 다음보기를 다시 추가하고 작동하는지 확인하는 것이 좋습니다.
ViewGroup parent = (ViewGroup) viewPager.getParent(); // get the view parent
if (parent != null) {
parent.removeView(viewPager); // remove the view
viewPager.getAdapter().notifyDataSetChanged(); // notify that the data has changed
parent.addView(viewPager); // then, re-add the view
}
출처
https://stackoverflow.com/questions/39929983