Reputation: 161
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..
Upvotes: 0
Views: 175
Reputation: 13825
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);
}
}
Upvotes: 2