如果不这样处理,在更新adapter的内容后,应该调用一下adapter的notifyDataSetChanged方法
adapter = new MyViewPagerAdapter();在需要更新的地方调用一下adapter的notifyDataSetChanged方法
if (listview != null) {
adapter.notifyDataSetChanged(); //修改地方
MustPlayAdapter adapter = (MustPlayAdapter)listview.getAdapter();
adapter.setDataList(list);
adapter.notifyDataSetChanged();
}
viewpager加载相同数据加载问题
public Object instantiateItem(ViewGroup container, int position) {
MustPlayAdapter adapter = new MustPlayAdapter(mContext);
if(isFirst) {
adapter.setDataList(dataBean.WillTravelsPoi);
isFirst=false;
}
listview.setAdapter(adapter);
}
优化代码
Cursor userCursor = getContentResolver().query(Uri.parse(calanderURL), null, null, null, null);
try {
if (userCursor.getCount() > 0) {
userCursor.moveToLast();
calId = userCursor.getString(userCursor.getColumnIndex("_id"));
} else {
Toast.makeText(this, "没有账户,请先到日历添加账户", Toast.LENGTH_SHORT).show();
return;
}
} finally {
userCursor.close();
}
private Paint paint = new Paint(); //paint 在onDraw外new对象
protected void onDraw(Canvas canvas) {
paint.setAntiAlias(true);
}