简体   繁体   中英

I want to show the background process of progressdialog when retriving data from listview in Android

I want to retrieve data from database. So i decided to use ProgressDialog .

I want to allow the user to see how many records to be added to the list view in background . please help me,

Thanks in Advance..

Use AsyncTask like below to show 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);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM