ActionBarSherlock - Style contains key with bad entry

霸气de小男生 提交于 2019-12-18 03:04:26

问题


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" />

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;
  }
}

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.

Any suggestions? Thanks!


回答1:


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.

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

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.

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



来源:https://stackoverflow.com/questions/9686818/actionbarsherlock-style-contains-key-with-bad-entry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!