The application’s PagerAdapter changed the adapter’s contents without calling PagerA

ATAL EXCEPTION: main java.lang.IllegalStateException: The application’s PagerAdapter changed the adapter’s contents without calling PagerAdapter#notifyDataSetChanged! 

出错原因:数据更新必须在main thread进行更新!!结束前还得调用 notifyDataSetChanged() !!

我的具体做法即:

final MyPagerAdapter adpater = new MyPagerAdapter(getSupportFragmentManager());

final ViewPager viewFlipper = (ViewPager) findViewById(R.id.pager);

runOnUiThread(new Runnable() {//在主线程里面设置adpater

@Override

public void run() { 

// TODO Auto-generated method stub

viewFlipper.setAdapter(adpater);

}

});

adpater.notifyDataSetChanged();//然后再通知数据改变,与setAdapter()一起放在runOnUiThread()里面亦可


你可能感兴趣的:(PagerAdapter,contents,the,Changed,the,calling,Without,application’s,adapter’s)