0

我想从数据库中检索数据。所以我决定使用ProgressDialog.

我想让用户在后台查看要添加到列表视图中的记录数。请帮我,

提前致谢..

4

1 回答 1

2

使用如下所示的 AsyncTask 来显示 ProgressDialog

    private class FetchRSSFeeds extends AsyncTask<String, Void, Boolean> {

    private ProgressDialog dialog = new ProgressDialog(HomeActivity.this);

    /** progress dialog to show user that the backup is processing. */
    /** application context. */

    protected void onPreExecute() {
        this.dialog.setMessage("Please wait");
        this.dialog.show();
    }

    protected Boolean doInBackground(final String... args) {
        try {

            /**
             * Fetch the data
             */
            Utilities.arrayRSS = objRSSFeed.FetchRSSFeeds(Constants.Feed_URL);
            return true;
        } catch (Exception e) {
            Log.e("tag", "error", e);
            return false;
        }
    }

    @Override
    protected void onPostExecute(final Boolean success) {

        if (dialog.isShowing()) {
            dialog.dismiss();
        }

          // Setting data to list adaptar
          setListData();
          txtTitle.setText(Utilities.RSSTitle);
    }
}
于 2012-07-25T05:06:46.327 回答