나는 뷰포트를 설문지로 사용하고 있습니다. 사용자가 처음 8 개 단편에서 대답을 입력하면 응답이 10 번째 단편 (OverviewFragment)에 표시됩니다. 모두 잘 작동합니다. 사용자가 이전 조각으로 돌아갈 때 즉, 조각 4 및 응답을 변경합니다. 조각이 업데이트되지 않은 10 번째 조각으로 돌아 가면 응답을 변경합니다. 이것은 lifecycle/backstack 문제이지만 뷰 페이지에서 백 스택에서 조각을 걷어차는 방법을 확신 할 수 없습니다. 또는 프래그먼트를 지속적으로 새로 고치는 방법 일 수도 있습니다.뷰 페이지의 백 스택에서 조각을 제거하고 이전에 본 프래그먼트를 새로 고침
public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
private int fragmentCount = 11;
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
switch (position){
case 0:
return DemoFragment.newInstance();
case 1:
return PreliminaryQuesFragment.newInstance();
case 2:
return QuestionOneFragment.newInstance();
case 3:
return QuestionTwoFragment.newInstance();
case 4:
return QuestionThreeFragment.newInstance();
case 5:
return QuestionFourFragment.newInstance();
case 6:
return QuestionFiveFragment.newInstance();
case 7:
return QuestionSixFragment.newInstance();
case 8:
return StatementFragment.newInstance();
case 9:
return OverviewFragment.newInstance(user.getTitle(), prelimAnswer, qOne, qTwo,
qThree, qFour, qFive);
case 10:
return GoodbyeFragment.newInstance(position);
default:
return null;
}
}
@Override
public int getCount() {
return fragmentCount;
}
}