The content of the adapter has changed but ListView did not receive a notification 你的adapter没有刷新 class MyHandler extends Handler { @Override public void handleMessage(Message msg) { HashMap<String, String> hashMap = (HashMap<String, String>) msg.obj; list.add(hashMap); 这里加上adapter.notifyDataSetChanged(); }
还有你的代码的质量不太好, thread = new MyThread(); thread.start();这个有什么用。 public void handleMessage(Message msg) { 这里面最好用switch(msg.what)判断一下 } 调用handler.sendE...
你的adapter没有刷新
class MyHandler extends Handler { @Override
public void handleMessage(Message msg) {
HashMap<String, String> hashMap = (HashMap<String, String>) msg.obj;
list.add(hashMap);
这里加上adapter.notifyDataSetChanged();
}
thread = new MyThread();
thread.start();这个有什么用。
public void handleMessage(Message msg) {
这里面最好用switch(msg.what)判断一下
}
调用handler.sendE...
我查资料时别人也是这样说,但加上这句后报空指针异常(就单单加这一句,其它什么都没改),求指教。
你这个是demo吗?发给我给你调调
2.就是确保setadapter的值是在此类里面public MyAdapter(Context context,ArrayList<ShowParams> sList){
super();
this.context=context;
this.sList=(ArrayList<ShowParams>) sList.clone();
this.inf=LayoutInflater.from(context);
}
也就是将this.sList=sList;改为this.sList=(ArrayList<ShowParams>) sList.clone();就行了