2012-06-18 4 views
0

파일에서 데이터를 읽는 중 -> DB에 저장 -> DB에서 데이터를 가져 와서 내 사용자 지정 ListView로드 중 ... DB에 데이터 가져 오기 및 저장 중 ProgressDialog를 표시하려고합니다.ListView 내용을로드하기 전에 진행 대화 상자 표시

AlertDialog alertDialog = AlertDialog.show(CommoditiesListScreen.this, "Importing..."); 

// importing data from file 
// Saving data to the DB 

alertDialog.dismiss(); 

유형 2 :

UiDialog uiDialog = new UiDialog(CommoditiesListScreen.this); 
CommoditiesListScreen.this.runOnUiThread(uiDialog); 
AlertDialog alertDialog = AlertDialog.show(CommoditiesListScreen.this, "Importing..."); 
alertDialog.getWindow().makeActive(); 


// importing data from file 
// Saving data to the DB 

uiDialog.stopDialog(); 
alertDialog.dismiss(); 

내가 N 두 가지 방법으로 시도 내 화면이 나는이 두 가지 유형 하지만

유형 1을 작동하지 않는 그 시도 ot 작업 중, ProgressDialog가 화면에 나타나지 않습니다. 추가 한 내용이나 수정 한 내용은 저에게 도움이됩니다 ...

참고 : Forgot call dismiss(); 유형 1에 진행 ListView에 후로드가 나타납니다 그리고

+0

가져 오기, DB에 저장 및 목록보기에서 비동기 작업을 사용합니다. 비동기 작업의 사전 실행에서 경고 대화 상자를 시작하고 실행 후 대화 상자를 닫습니다. – rajpara

+0

고마워요, 내 코드에 스레드 문제가 있습니까? plch 도움말을 참조 할 수 없습니다. – Pradeep

+0

http://developer.android. co.kr/reference/android/os/AsyncTask.html – rajpara

답변

2

이것은 당신이 방법 onPreExecute()dialog을 보여줄 수있는 AsyncTask를 사용하는 이상적인 상황, 파일에서 배경 작업 (읽기 데이터를 수행 .. 무한 시간 동안 회전 -> DB에 저장) doInBackground() 메서드에 넣고 onPostExecute() 메서드에서 목록을로드하고 표시합니다.