动作条scherlock不会刷新时,方向改变 [英] Actionbar scherlock is not refreshed when the orientation is changed

查看:96
本文介绍了动作条scherlock不会刷新时,方向改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用福尔摩斯的动作条在我的应用程序。我用ifRoom | withText功能在我的菜单。如果我测试我的code在纵向模式下,我只能看到图标,如果我旋转方向为横向,还是我只看到图标。在另一方面,如果我与景观跑,我可以看到纵向和横向的文字和图标。这意味着,当屏幕旋转时,操作栏未刷新。我该如何解决?

在菜单中,我有

 安卓showAsAction =ifRoom | withText
 

此外,我用我的清单文件中此行的固定

 安卓configChanges =keyboardHidden |方向|屏幕尺寸
 

但没有奏效。我跑我的code的Andr​​oid 2.3

另外我在活动中使用的片段,

  FragmentManager FM = getSupportFragmentManager();
    英尺= fm.beginTransaction();

    mFragment1 = fm.findFragmentByTag(F1);

    如果(mFragment1 == NULL){

        mFragment1 =新MenuFragment();
        ft.add(mFragment1,F1);

    }

    ft.commit();
 

解决方案

处理配置更改不支持ActionBarSherlock。

在pre-ICS,ActionBarSherlock并不像本地操作栏上的装饰视图的一部分,并因此受到相同的限制内容视图。通过处理配置更改你是不是允许库,以适应变化,因此会看到不正确的显示或某些部分。

Android的文档不鼓励处理的配置变化,以及。避免他们不惜一切代价,尤其是在使用ActionBarSherlock。

在一个相关的说明,我还在试图解决此为图书馆的未来版本,但现在避免建议。

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();

解决方案

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.

这篇关于动作条scherlock不会刷新时,方向改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆