Posted on Leave a comment

ProgressDialog, ProgressBar

The simpliest way to show progress in ActionBar is

        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setContentView(R.layout.activity_main);


and then call

        setProgressBarIndeterminateVisibility(true);

to show progressbar

Use ProgressDialog

            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();

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.