原因:
触发返回按钮后跳转到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();//向服务请求数据
}
即可成功解决。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。