ActionBar.selectTab doesn't refresh spinner in

2019-07-04 18:47发布

问题:

In an application, I'm using Tabs with the ActionBar, and sometimes I switch tabs programatically using the ActionBar.selectTab() method.

This works well but when the width of the ActionBar is too small, the tabs go in compact mode, and are displayed as a drop down menu. And when I use the ActionBar.selectTab() method, the displayed item in the spinner doesn't change.

Is there an official solution for this or a known workaround ?

回答1:

This is a known bug in Android. Please look at a workaround suggested by Jake Wharton here: and star the issue so it gets fixed



回答2:

This problem has been asked on ActionBarSherlock github. It seems that this problem also exists on the ICS ActionBar.

It can be avoided with ABS by changing the source as stated in the link. For the native ActionBar, I managed to make a workaround using reflection to access the action bar's dropdown spinner.