Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intermediate Progress doesn't work with ActionBarSherlock running on Gingerbread

I setup ActionBarSherlock with my app, and I'm trying to use the Intermediate Progress, I'm using this:

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);    
    setSupportProgressBarIndeterminateVisibility(false);

In my onCreate, and then using:

    setSupportProgressBarIndeterminateVisibility(true);

To enable it.

It works fine in ICS but it doesn't work at all in Gingerbread or Froyo, does anyone know how to get it to work? Thanks

like image 913
William L. Avatar asked Jul 09 '12 20:07

William L.


2 Answers

I just had the same problem. Jake's solution above did not fix it for me - the method is undefined.

I found a working solution posted by Jake on the bug list for ActionBarSherlock here:

  • Action Bar Indeterminate Progress Bar Not Disappearing

See Jake's response to the poster - the trick is to call getSupportActionBar() first, to "trigger creation of the views".

So my onCreate() method is:

protected void onCreate(Bundle arg0)
{
    super.onCreate(arg0);

    // allow window to show progress spinner in the action bar
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    getSupportActionBar();
    setSupportProgressBarIndeterminateVisibility(false); 
}

Update based on comment from Laux:

Make sure your imports reflect com.actionbarsherlock.view.Window.FEATURE_INDETERMINATE_PROGRESS for this to work.

Here is part of my import block from an app that uses this pattern:

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.ActionProvider;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
import com.actionbarsherlock.widget.ShareActionProvider;

This is a very good thing to remember when working with ABS - many of your normal Android imports should be updated to refer to ABS instead.

It may be a good idea to revisit your import block, or possibly remove it entirely and let Eclipse rebuild it for you (CTRL-SHIFT-O) to which point Eclipse will prompt you for each import that ABS redeclares.

This was also explained by Glebbb in his answer.

like image 70
Richard Le Mesurier Avatar answered Oct 20 '22 19:10

Richard Le Mesurier


I'm sure you've probably figured it out by now, but the most likely culprit is you including the wrong file because it's so easy to do automatically.

Replace any import of android.view.Window with com.actionbarsherlock.view.Window and the needed features will work.

like image 33
Glebbb Avatar answered Oct 20 '22 19:10

Glebbb