Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actionbar scherlock is not refreshed when the orientation is changed

I use Sherlock action bar in my application. I used "ifRoom|withText" feature in my menu. If I test my code in portrait mode, I can see only icon and if I rotate orientation to landscape, still I see only icon. On the other hand, if I run with landscape, I can see text and icon on portrait and landscape. This means that When the screen is rotated, action bar is not refreshed. How can I fix?

In menu, I have

    android:showAsAction="ifRoom|withText"

Also I used this line in my manifest file to fixed

    android:configChanges="keyboardHidden|orientation|screenSize"

but it didn't work. And I run my code android 2.3

Also I used fragment in my activity,

        FragmentManager fm = getSupportFragmentManager();
    ft = fm.beginTransaction();

    mFragment1 = fm.findFragmentByTag("f1");

    if (mFragment1 == null) {

        mFragment1 = new MenuFragment();
        ft.add(mFragment1, "f1");

    }

    ft.commit();
like image 754
SavasCinar Avatar asked May 14 '12 19:05

SavasCinar


1 Answers

Handling configuration changes is not supported with ActionBarSherlock.

On pre-ICS, ActionBarSherlock is NOT part of the decor view like the native action bar and is therefore subject to the same restrictions as your content view. By handling configuration changes you are not allowing the library to adapt to the change and therefore will see incorrect display or certain parts.

The Android documentation discourages handling config changes as well. Avoid them at all costs, especially when using ActionBarSherlock.

On a related note, I'm still trying to work around this for future versions of the library but for now avoiding is recommended.

like image 71
Jake Wharton Avatar answered Oct 20 '22 09:10

Jake Wharton