我有一个显示进度对话框的方法......并且在一个单独的线程上我正在执行 3 个 HTTP 请求......
这是代码...
public void downloadData(View v)
{
final ProgressDialog prog;
try
{
// setup progress dialog
prog = new ProgressDialog(this);
prog.setTitle("Downloading Data");
prog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
prog.setIcon(R.drawable.firstdroidicon);
prog.setCanceledOnTouchOutside(false);
prog.setCancelable(false);
prog.show();
Thread syncThread = new Thread();
syncThread = new Thread()
{
public void run()
{
String result = "";
String URL = //url for ReST service
String urlParams = "";
GetByREST gbr = new GetByREST();
// run the customer search
prog.setMessage("Fetching Customers");//update progress dialog
result = //execute first post
// run the contact search
prog.setMessage("Fetching Contacts");//update progress dialog
result = //execute second post
// run the item saved search
prog.setMessage("Fetching Items");//update progress dialog
result = //execute third post
prog.dismiss();
};
syncThread.start();
}
catch (Exception e)
{
messageBox("downloadData", e.getMessage());
}
}
如何在每个请求之前更新进度对话框消息?