2011-06-12 54 views
1

我想更新進度條,使用的AsyncTask 的方法調用我的代碼看起來像這樣問題用的AsyncTask

private class ProgressBar extends AsyncTask<Void, Integer, Integer> 
{ 
protected Integer doInBackground(Void... params) 
{ 
    int a=2; 
    for(int i=0;i<=100;i=i+5) 
    { 
     SystemClock.sleep(1000); 
     publishProgress(i); 
    } 
    return a; 
} 

protected void onProgressUpdate(Integer... item) 
{ 
    //int no_of_argruments=item.length; 
    tv.setText("Over !!"+item[0]); 
    bar.setProgress(item[0]); 
} 

protected void onPostExecute() 
{ 
    if(result[0]!=null) 
    { 
     tv.setText("Hurray !!"); 
     Toast.makeText(checkThread.this, "Done!", Toast.LENGTH_SHORT) 
     .show(); 
    } 
} 

但在doInBackground()的completipon,我onPostExecute()不叫,進度條只是掛起它的最終價值。

如何調用onPostExecute()方法?

回答

0

這是postExecute正確的簽名()

protected void onPostExecute (Result result) 

你的方法是你自己的方法AsyncTask沒有關於知識。