原因:
触发返回按钮后跳转到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();//向服务请求数据
}
即可成功解决。
本文出自 “新起点” 博客,请务必保留此出处http://10042542.blog.51cto.com/10032542/1686204
listview点击item后跳转到详细页面后返回listview数据不显示问题
原文地址:http://10042542.blog.51cto.com/10032542/1686204