[問題] ProgressDialog和AlertDialog怎麼結合
不好意思想要請問一下,AlertDialog和ProgressDialog要怎麼樣結合?
<以下是我目前的code>
AlertDialog.Builder info_2 = new AlertDialog.Builder(main.this);
info_2.setTitle("state");
info_2.setMessage("done");
info_2.setPositiveButton("ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
try {
//mycode
AlertDialog.Builder info_3 = new AlertDialog.Builder(main.this);
info_3.setTitle("state");
info_3.setMessage("done");
info_3.setPositiveButton("ok", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
// TODO Auto-generated method stub
}
});
info_3.show();
} catch (Exception e) {
// TODO: handle exception
}
}
});
info_2.show();
----------------------------------------
不好意思有一點多,但他其實就是在出現一個對話框之後,按下ok
會去跑code,跑完之後會再跳出另一個對話框
因為中間要跑的code要花的時間比較長,所以想要用ProgressDialog來做一個提示
避免讓別人覺得程式掛掉了,
目前有試著把
ring=ProgressDialog.show(main.this, "Please wait", "Loading please wait..",
true);
ring.setCancelable(true);
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try
{
Thread.sleep(15000);
}catch(Exception e){}
final{
ring.dismiss();
}
}
}).start()
這份code直接接在onClick(DialogInterface dialog, int which)下面,try上面
可是這樣寫的結果都會變成,等到全部程式(整個系統跑完)跑完後,
ProgressDialog的提示才會在螢幕上轉轉轉,不知道是什麼原因@@
所以想要請問一下,不知道ProgressDialog要怎麼結合在當中呢?
謝謝大家!!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.242.2.95
推
12/23 23:16, , 1F
12/23 23:16, 1F
推
12/24 00:12, , 2F
12/24 00:12, 2F
→
01/05 15:46, , 3F
01/05 15:46, 3F
討論串 (同標題文章)