안녕하세요.
오늘 질문 많이 올리네요 -_-;
현재 onCreateDialog에서 ProgressDialog를 생성하여
파일을 다운로드 받는데 진행상태를 보여주고 있습니다.
이게 네트워크 문제로 재시도를 할 때
진행상태가 0부터 나와야 하는데
onPrepareDialog에서 setProgress(0)으로 해봐도 다이얼로그가 나타나는 시점엔 기존 값이 남아있네요;
@Override
protected void onPrepareDialog(int id, Dialog dialog) {
super.onPrepareDialog(id, dialog);
switch (id) {
case DIALOG_PROGRESS_DB_DOWNLOAD :
((ProgressDialog)dialog).setProgress(0);
// dbDialog.setProgress(0);을 해도 안됩니다;
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// dbDialog.setProgress(0);
// }
//}); 해도 안됩니다;
}
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_PROGRESS_DB_DOWNLOAD :
Log.d("BestDoctor", "DIALOG_PROGRESS_DB_DOWNLOAD");
dbDialog = new ProgressDialog(this);
dbDialog.setTitle(R.string.dbDownload);
dbDialog.setCancelable(false);
dbDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dbDialog.setIndeterminate(false);
return dbDialog;
}
}
일단 대화창이 뜨고 진행상태가 변하면 0부터 시작을 하지만 처음 딱 떴을 때는 이전 진행상태가 남아있습니다;
전 onPrepareDialog만 있으면 다 해결될 줄 알았는데 말이죠 ㅠㅠ
The setup is simple. Most of the code needed to create a progress dialog is actually involved in the process that updates it. You might find that it's necessary to create a second thread in your application for this work and then report the progress back to the Activity's UI thread with a Handler object. If you're not familiar with using additional threads with a Handler, see the example Activity below that uses a second thread to increment a progress dialog managed by the Activity.
ui 쓰레드 움직이려면 핸들러 쓰라고 하는거 같은데용?




protected void onPrepareDialog (int id, Dialog dialog)
This method is deprecated.
Old no-arguments version of
onPrepareDialog(int, Dialog, Bundle).디스프리케이티드 되어있다네요 ~~~!!!!!!!