原因:
触发返回按钮后跳转到listview主界面,数据要重新加载,这时要想加载数据,就要在启动Activity的时候程序自动加载,而handler里面写的是主线程,一定会执行,所以在后面添加
/**
* 处理消息(主线程),更新适配器,如果在Thread里处理可能会出错
* */
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case Util.DOWNLOAD_START:
progressDialog.show();
// progressDialog.SetMessage(msg.getData().get("text")
// .toString());
Toast.makeText(CheckOrderActivity.this, Util.CurrentMessage,
Toast.LENGTH_LONG).show();
break;
case Util.DOWNLOAD_END:
progressDialog.dismiss();
break;
case Util.DOWNLOAD_OK:
threadContinue=false;//结束线程
Toast.makeText(CheckOrderActivity.this, Util.CurrentMessage,
Toast.LENGTH_LONG).show();
SetDatatoUI();
progressDialog.dismiss();
break;
case Util.DOWNLOAD_ERROR:
progressDialog.dismiss();
Toast.makeText(CheckOrderActivity.this, "没有账单信息", Toast.LENGTH_LONG)
.show();
break;
case Util.DOWNLOAD_DISCONNECT:
progressDialog.dismiss();
AlertDialog.Builder builder = new Builder(CheckOrderActivity.this);
builder.setMessage("未连接上网络!");
builder.setTitle("提示");
builder.setPositiveButton("确认",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
builder.create().show();
break;
}
super.handleMessage(msg);//执行父类的方法
}
};
adapter = new MyAdapterr(CheckOrderActivity.this, Fieldlist);
search();//向服务请求数据
}
即可成功解决。