private final Handler handler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
int state = msg.getData().getInt("state");
switch (state) {
case FINISH:
ArrayList<ImageList> templist = msg.getData()
.getParcelableArrayList("list");
if (templist.size() < load_count) {
loadMore = false;
}
if (adapter == null) {
adapter = new Gallery_Adapter(context, 0, templist);
// set adapter
gallery.setAdapter(adapter);
} else {
adapter.notifyDataSetChanged();//调用这个函数后getview()的position没有变为0
}
break;
}
super.handleMessage(msg);
}
};
用ArrayAdapter实现Gallery翻页,每次查询完成后跳到该Handler,对ArrayAdapter中的数据进行更改,但是得不到效果,谁能说下这过程吗? 调用notifyDataSetChanged()这个方法后,是不是不用再另外进行数据改变的通知?或者说该不adapter为null了,调用notifyDataSetChanged()后会自动通知数据更改为新的templist,因为每次回到Handler都会得到新的templist?
|
|