【发布时间】:2013-05-23 10:48:57
【问题描述】:
final Dialog Alert_Dialog = new Dialog(MainList.this);
Alert_Dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
Alert_Dialog.setContentView(R.layout.alert_dialog_progressbar);
((TextView)Alert_Dialog.findViewById(R.id.txtMessage)).setText(R.string.please_wait_);
Alert_Dialog.setCancelable(false);
Alert_Dialog.show();
((Button) Alert_Dialog.findViewById(R.id.btnCancel)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Alert_Dialog.cancel();
}
});
然后像这样调用 AsynTask :
String res="";
try{
SendingWebPageTask sendMaster=new SendingWebPageTask();
res=sendMaster.execute(UrlMaster).get();
}catch (Exception e) {
e.printStackTrace();
}
我正在返回基于响应的 url 响应我的值,我正在调用第二个 url,但问题是当我以这种方式从异步任务返回值时,它不会显示对话框并且它会挂起设备直到 asynTask无法完成它的任务,所以任何人都可以帮助我。
【问题讨论】:
-
那么还有其他方式来显示进度条并从 AsyncTask 返回值吗?
-
@PankajKumar 什么??没有解决方案我是对的?
-
so anyother way to display progress bar and return value from AsyncTask先生不是解决方案吗? -
现在你已经开始在这里开玩笑了..
-
:没问题。我建议你从对话框中调用 asynctask,(在你取消对话框的同一个地方)然后在 asyntask 的 postexecute 上更新
res的值......现在这不是一个笑话......跨度>