Posted on Leave a comment

ProgressDialog, ProgressBar

The simpliest way to show progress in ActionBar is

[code language=”java”]
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.activity_main);
[/code]


and then call

[code language=”java”]
setProgressBarIndeterminateVisibility(true);
[/code]

to show progressbar

Use ProgressDialog

[code language=”java”]
ProgressDialog pd;
pd = new ProgressDialog(this);
pd.setMessage("downloading…");
pd.setIndeterminate(true);
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd.setCancelable(true);
pd.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
// TODO if canceled (e.g. user pressed BackButton)
}
});
pd.show();
[/code]

Also

ProgressBar under ActionBar (pdf)

How to show progress (pdf)

SwipeRefreshLayout (pdf)

AsyncTaskManager (pdf, source)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.