我想在從服務器下載的同時使用進度條,實際上我使用的是progressDialog,但是如果我使用progressBar而不是progressDialog.I,我會爲Progress對話框提供以下代碼。使用progressBar而不是ProgressDialog
public class FeaturedData extends AsyncTask<Void, Void, Void> {
Home home;
ProgressDialog dialog = null;
public FeaturedData(Home home) {
// TODO Auto-generated constructor stub
this.home = home;
}
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
//calling here method
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
dialog.dismiss();
}
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
dialog = ProgressDialog.show(home, "", "", true);
}
GONE [見本](http://stackoverflow.com/q/4119009/940096)&[This this](http://android-er.blogspot.in/2010/11/progressbar-running-in-asynctask.html) – Praveenkumar
您是否嘗試過Google搜索它?這是第一個結果! –
其實我想以編程方式做它不想在xml中聲明。 – Jay