【问题标题】:Android : How do I use the ActionBarSherlock on older versions of Android?Android:如何在旧版本的 Android 上使用 ActionBarSherlock?
【发布时间】:2013-12-20 21:36:18
【问题描述】:

我正在开始开发应用程序,并将目标设置为 Android 2.2。我可以在我的应用程序中使用 actionbarsherlock 吗?

我在 pom 文件中添加了以下代码:

<dependency>
            <groupId>com.google.android</groupId>
            <artifactId>support-v4</artifactId>
            <version>r7</version>
        </dependency>

        <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>actionbarsherlock</artifactId>
            <version>4.4.0</version>
        </dependency>

但我的应用程序无法在我的 android 2.2 手机中运行,并且出现此错误:

java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.

在这种情况下,我在做什么?

当我在 AndroidManifest.xml 中设置android:theme="@style/Theme.Sherlock" 时出现此错误:

Android 资源打包:错误:找不到与给定名称匹配的资源(在“主题”处,值为“@style/Theme.Sherlock”)。

【问题讨论】:

  • 您应该使用建议的主题之一,只需在 AndroidManifest.xml 中设置主题名称您还应该查看 appcompat 项目 - 这是 ABS 的 google 替换
  • 我完成了我的猜测。

标签: android android-actionbar


【解决方案1】:

您只需将此属性添加到清单文件android:theme="@style/Theme.Sherlock"中的应用程序标签中

应该添加库作为参考,以便能够使用 Sherlock 主题。要在 IntelliJ 中添加库,请检查 this out:

【讨论】:

  • 当我在 AndroidManifest.xml 中设置 android:theme="@style/Theme.Sherlock" 时出现此错误:Android Resource Packaging: E​​rror: No resource found that match the given name (at 'theme'值为“@style/Theme.Sherlock”)。
  • 尝试在您的 sherlock 依赖项中添加 &lt;type&gt;apklib&lt;/type&gt;
  • 如何添加 actionbarsherlock 作为参考?在哪里?
  • 您使用的是哪个 IDE?
【解决方案2】:

我认为你应该从website.下载actionbarsherlock 我不知道如何在IntelliJ中导入它,但也许你可以在eclipse IDE中导入你的项目(如果你没有的话在官方网站上下载它)然后将 actionbarsherlock 导入 Eclipse,将其作为库添加到您的应用中,然后在配置完成后,再次将项目导入 IntelliJ。

【讨论】:

    【解决方案3】:

    要在低于该 API 级别的 API 中使用 ActionBar,您可以使用 ActionBarSherlock

    【讨论】:

      【解决方案4】:

      只需在AndroidManifest 文件中的application 标记中使用android:theme 作为@style/Theme.Sherlock.Light.DarkActionBar 或任何其他sherlock 样式

      【讨论】:

      • 当我在 AndroidManifest.xml 中设置 android:theme="@style/Theme.Sherlock" 时出现此错误:Android Resource Packaging: E​​rror: No resource found that match the given name (at 'theme'值为“@style/Theme.Sherlock”)。
      • 您是否将 sherlock 操作栏库添加到您的项目中?
      • 不,我没有将它添加到我的项目中,应该添加吗?
      【解决方案5】:

      您可能需要更新 AndroidManifest.xml 中的主题

      <application
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/Theme.Sherlock">
      

      【讨论】:

      • 当我在 AndroidManifest.xml 中设置 android:theme="@style/Theme.Sherlock" 时出现此错误:Android Resource Packaging: E​​rror: No resource found that match the given name (at 'theme'值为“@style/Theme.Sherlock”)。
      猜你喜欢
      • 1970-01-01
      • 2012-09-09
      • 1970-01-01
      • 1970-01-01
      • 2021-01-23
      • 2012-07-01
      • 1970-01-01
      • 2015-01-03
      • 2016-05-30
      相关资源
      最近更新 更多