2011-02-27 4 views
0

내가 다음과 같이Android : progressbar 대화 상자를 표시하는 데 문제가 있습니까? 함수가 실행을 완료 한 후 내 응용 프로그램에서

내 코드의 정의는 ... 실행을 완료하고 그것을 해제하는 기능에 대한 찍은 시간 동안 진행 막대를 표시하려고 :

protected Dialog onCreateDialog(int id) { 
     switch (id) { 
      case PROCESS: { 
       ProgressDialog dialog = new ProgressDialog(this); 
       dialog.setTitle("Indeterminate"); 
       dialog.setMessage("Please wait while loading..."); 
       dialog.setIndeterminate(true); 
       dialog.setCancelable(true); 
       return dialog; 
      } 
     } 
     return null; 
    } 




showDialog(PROCESS); 
doFunction(); 
dismissDialog(PROCESS); 

과 processdialog가 표시되지되지 않는 몇 가지 이유 ...

은 어떤 사람이 ... 그것을 할 수있는 다른 방법이 .... PLS 나를 여기에 도울 수

답변

2

:주셔서 감사 기능을 처리하는 데 시간이 걸리므로는

new AsyncTask<Void, Void, Void>() { 

     @Override 
     protected void onPreExecute() 
     { 
      pd = ProgressDialog.show(getApplicationContext(),"", "Sending Image ...", true); 
      Log.d(TAG, "onPreExecute()"); 
     } 

     @Override 
     protected Void doInBackground(Void... params) 
     { 
      doFunction(); 
      return null; 
     } 

     @Override 
     protected void onPostExecute(Void res) 
     { 
      Log.d(TAG, "onPostExecute()"); 
      pd.dismiss(); 
     } 
    }.execute(); 

가 두 번째로 불확정로 설정하면 만 원 꼬추를 볼 것을 의미 비동기 작업을 사용합니다.

당신은 내가 이것을 시도했지만 내가 android.view.WindowManager $ BadTokenException '...과 같은 오류를 얻고있다 progress style

+0

STYLE_HORIZONTAL에 설정해야합니다 창을 추가 할 수 없습니다 - 토큰 널 (null)이 아니입니다 응용 '.... .... 사람을 도울 수 있습니다 .... – kAnNaN

관련 문제