ActionBarSherlock - 样式包含有错误项关键有错误、样式、关键、ActionBarSherlock

2023-09-04 04:42:25 作者:驯服我

我试图使用 ActionBarSherlock 中,我在清单中这样声明了一个具体的活动:

I'm trying to use ActionBarSherlock in one specific activity which I've declared in the Manifest like this:

<activity
        android:name=".activities.Bla"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.Sherlock" />

我的动态code是这样的:

My Activity code is this:

public class Bla extends SherlockFragmentActivity implements ActionBar.OnNavigationListener {

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bla);
    getSupportActionBar().setTitle("");
    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    Context context = getSupportActionBar().getThemedContext();
    ArrayAdapter<CharSequence> list =
        ArrayAdapter.createFromResource(context, R.array.cartaz_filters, R.layout.actionbar_spinner_item);
    list.setDropDownViewResource(R.layout.actionbar_spinner_dropdown_item);
    getSupportActionBar().setListNavigationCallbacks(list, this);
  }

  @Override
  public boolean onNavigationItemSelected(int itemPosition, long itemId) {
    return true;
  }
}

不过,我每次运行这个在Android 2.1出现以下错误:

However, every time I run this in an Android 2.1 I get the following error:

E/ResourceType(9672): Style contains key with bad entry: 0x01000000

我想这可能与这个问题有关:读取较新的主题属性在较早的平台,但我不知道如何解决它。

I think this might be related with this question: Read Newer Theme Attributes On Older Platform but I don't know how to solve it.

有什么建议?谢谢!

推荐答案

这是因为您使用的不是在其上运行的应用程序在该平台上present主题属性。尽管巨红错误日志,它增加,它更警告的,因为它不会影响到其他属性。较新的属性是从来不看的旧平台。

This is because you are using theme attributes that were not present on the platform on which you are running your application. Despite the giant red error log that it adds, it's more of a warning as it does not affect the other attributes. The newer attributes are never read on the older platforms.

这是我所链接的问题是我的尝试没有要求ABSv4使用镜像属性。

The linked question from me was my attempt to not have to require ABSv4 use mirrored attributes.

如果你真的想摆脱错误的,你可以创建两套您的风格。一个在值/ 在兼容性操作栏和一个值-V14 / 使用了prefixed属性对于本机操作栏。

If you really want to get rid of the error you can create two sets of your styles. One in values/ for the compatibility action bar and one in values-v14/ that use the prefixed attributes for the native action bar.

和请,请,请,请不要使用 maxSdkVersion 。使用 targetSdkVersion 代替。

And please, please, please, please do not use maxSdkVersion. Use targetSdkVersion instead.