我的适配器ViewPager在调用notifyDataSetChanged
后无法更新我的代码中的错误在哪里?
public class MyObjectAdapter extends PagerAdapter {
.....
public MyObjectAdapter(Activity activity, ArrayList<MyObject> myObjectList) {
this.activity = activity;
this.data = myObjectList;
mLayoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
.....
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view = mLayoutInflater.inflate(R.layout.item_list, container, false);
MyObject myObject = data.get(position);
RobotoRegularTextView title = (RobotoRegularTextView) view.findViewById(R.id.title);
title.setText(myObject.title);
container.addView(view);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
@Override
public int getItemPosition(Object object) {
MyObject myObject = (MyObject) ((View) object).getTag();
int position = data.indexOf(myObject);
if (position >= 0) {
return position;
} else {
return POSITION_NONE;
}
}
}