Search code examples
androidactionbarsherlock

Force refresh of SherlockActionbar


Im using the ActionbarSherlock library and with this method I'm replacing the blue line with another color.

I have a different drawable for online, offline and connecting. So setting the color in a xml theme is not an option.

getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_transparent_disconnected));

enter image description here
On my nexus 4 (Android 4.3) this works perfectly and the color of the line changes immediately,
but on my galaxy S2 mini (Android 2.3.6) nothing happens until I open the navigation drawer, then the color changes aswell.

How can I force this refresh of the actionbar so that the color changes immediately on al devices?

Thanks


Solution

  • The solution is to call this.supportInvalidateOptionsMenu(); after setting the backgroundDrawable