java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receiv

java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receiv_第1张图片

意思大体是,你的adapter的内容变化了,但是你的ListView并不知情。请保证你adapter的数据在主线程中进行更改!

public class OrderAdapter extends BaseAdapter {

	private ArrayList> lists;
	private Context context;
	private Handler handler;
	private BranchIdCallBack branchIdCallBack;

	public OrderAdapter(ArrayList> list, Context context, Handler handler) {
		super();
		this.lists = list;
		this.context = context;
		this.handler = handler;
	}
	@SuppressWarnings("unchecked")
	public void setDeviceList(ArrayList> list) {  
        if (list != null) {  
            lists = (ArrayList>)list.clone(); 
            notifyDataSetChanged();  
        }  
    }  
  
    public void clearDeviceList() {  
        if (lists != null) {  
        	lists.clear();  
        }  
        notifyDataSetChanged();  
    }  

	@Override
	public int getCount() {
		return lists==null?0:lists.size();
	}

adapter数据发生变化要及时刷新。

你可能感兴趣的:(Android)