どのように使用できnotifyDataSetChanged
ますFragmentPagerAdapter
か?
中onResume
:
使っmMyFragmentPagerAdapter.notifyDataSetChanged();
たけどダメだった
しかし mMyFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
、働いている
public class Activity extends FragmentActivity{
static ViewPager mViewPager;
private MyFragmentPagerAdapter mMyFragmentPagerAdapter;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mViewPager = (ViewPager) findViewById(R.id.pager);
mMyFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
mViewPager.setAdapter(mMyFragmentPagerAdapter);
}
private static class MyFragmentPagerAdapter extends FragmentPagerAdapter {
...
}
@Override
protected void onResume() {
super.onResume();
//WORKS
mMyFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
mViewPager.setAdapter(mMyFragmentPagerAdapter);
//DOESN'T WORK
mMyFragmentPagerAdapter.notifyDataSetChanged();
mViewPager.setAdapter(mMyFragmentPagerAdapter);
}
}
移入:
public void startView() {
this.questions.clear(); // this.questions is a LinkedList
this.questions.add(q);
}