
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 0.71 KB | hits: 10 | expires: Never
First view in android by using progress bar
private class InsertDataTask extends AsyncTask<Void, Void, Void> {
private final ProgressDialog dialog = new ProgressDialog(Main.this);
// can use UI thread here, and you see we add a progress dialog
protected void onPreExecute() {
this.dialog.setMessage("Inserting data...");
this.dialog.show();
}
// automatically done on worker thread (separate from UI thread)
protected Void doInBackground(Void... args) {
//Do background work here
return null;
}
// can use UI thread here and we dismiss the progress dialog
protected void onPostExecute(final Void unused) {
if (this.dialog.isShowing()) {
this.dialog.dismiss();
}