ViewPager也是一个常用的组件 与ListView类似 当绑定数据后 想刷新数据 需要在适配器中添加如下方法
protected PagerAdapter galleryAdapter = new PagerAdapter() { @Override public boolean isViewFromObject(View arg0, Object arg1) { return arg0 == ((View)arg1); } @Override public int getCount() { return size; } @Override public Object instantiateItem(View container, int position) { return bindGalleryAdapterItemView(container, position); } @Override public void destroyItem(View container, int position, Object object) { ((ViewPager) container).removeView((View) object); }; @Override public void finishUpdate(View arg0) {} @Override public void restoreState(android.os.Parcelable state, ClassLoader loader) { }; @Override public Parcelable saveState() { return null; } @Override public void startUpdate(View arg0) {} @Override public int getItemPosition(Object object) {
//POSITION_NONE 是一个PagerAdapter的内部常量,值是-2, return POSITION_NONE; } };
以后有空写个专栏总结一下 http://stackoverflow.com/questions/7263291/viewpager-pageradapter-not-updating-the-view