Monday, 30 December 2013

Enable the Indeterminate progress bar in the Sherlock Action Bar

The Sherlock action bar comes itself with an indeterminate progress bar. To activate it, a new flag must be enabled, which must be before the content has been set:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Request the progress bar
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.activity_main);
    .....
     }

Once this flag is enabled, to enable the progress bar just do the follow:

setProgressBarIndeterminateVisibility(true);

And to disable it:
setProgressBarIndeterminateVisibility(false);



Be aware there when the flag is set, there are two imports possible. The one which is native is the good one:

import android.view.Window;

Source:

Others:

No comments:

Post a Comment