-1

我想在从服务器下载时使用进度条,实际上我使用的是progressDialog,但如果我使用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);
    }
4

1 回答 1

3

As per your below comment:

Actually i want to do it programatically don't want to declare in xml.

=> i would suggest you to take it inside the XMl layout.

  • Inside the onPreExecute(), make it visible using progressBar.setVisibility(View.VISIBLE)
  • and inside the onPostExecute(), make it GONE by using progressBar.setVisibility(View.GONE)
于 2012-06-23T11:35:04.520 回答