這是我的代碼& probelm。爲什麼ProgressDailog不顯示?
static Throwable t= null;
static String responseFromServer = "";
static Activity a ;
static Handler mHandler = new Handler();
public static String sendToServer(final Activity act, final String data)
{
progDailog = ProgressDialog.show(act, "", " Please wait...", true);
progDailog.setCancelable(true); //BUT this not displaying
Thread th = new Thread()
{
public void run(){
try{
// .........code ... SENDING data to server
responseFromServer = httpclient.execute(httppost, new BasicResponseHandler()).trim();
mHandler.post(showResponse);
}
catch (Exception e)
{
t = e;
e.printStackTrace();
progDailog.dismiss();
mHandler.post(exception);
}
}
};
th.start();
th.join();
return responseFromServer;
}
private static Runnable showResponse = new Runnable()
{
public void run(){
Toast.makeText(a, responseFromServer, Toast.LENGTH_SHORT).show();
progDailog.dismiss();
}
};
private static Runnable exception = new Runnable()
{
public void run(){
Toast.makeText(a, t + " ", Toast.LENGTH_SHORT).show();
progDailog.dismiss();
}
};
爲什麼progressdialog沒有顯示? 哪裏是顯示它的正確位置?
它的工作原理。非常感謝。 – Santhosh 2012-03-19 06:20:11
歡迎您。總是樂於提供幫助 – 2012-03-19 17:36:58