【问题标题】:Crash with android:background="?activatedBackgroundIndicator"与 android:background="?activatedBackgroundIndicator" 一起崩溃
【发布时间】:2013-06-14 20:39:26
【问题描述】:

我有一个与 ActionBarSherlock 声明相关的问题:

android:background="?activatedBackgroundIndicator"

问题是,如果我在这样的布局中使用这个值:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?activatedBackgroundIndicator">
.....

如果我使用主题,包含此 XML 崩溃的适配器:

<style name="AppTheme" parent="@style/Theme.Sherlock.Light.DarkActionBar">

但如果我将主题更改为:

<style name="AppTheme" parent="@style/Theme.Sherlock.Light">

这是 ActionBarSherlock 的错误吗?或者我做错了什么?重复它崩溃如果我 使用 Light.DarkActionBar 主题,但如果我使用 Light 主题,则可以使用。

我测试改变:

android:background="?activatedBackgroundIndicator"

为此:

 android:background="?android:attr/activatedBackgroundIndicator"

这是原始属性并且有效。

这是堆栈跟踪:

FATAL EXCEPTION: main
E/AndroidRuntime( 1574): android.view.InflateException: Binary XML file line #2: Error     inflating class...
....
E/AndroidRuntime( 1574): Caused by: android.content.res.Resources$NotFoundException:   Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010047 a=-1}
E/AndroidRuntime( 1574): at android.content.res.Resources.loadDrawable(Resource

提前致谢。

【问题讨论】:

  • 您正在尝试设置自定义activatedBackgroundIndicator?如果是,正确的方法是设置android:background="?android:attr/activatedBackgroundIndicator"

标签: android android-layout android-listview actionbarsherlock android-actionbar


【解决方案1】:

我在 ABS 存储库中创建了一个问题,SimonVT 说:

ABS 没有在 api14+ 上的 DarkActionBar 主题中定义它自己不使用的属性。该库并非旨在帮助您为应用设置主题。 除非 ABS 使用我们没有设置的属性。

所以我所做的是创建一个 layout-v11 文件夹,该文件夹具有该特定布局:

android:background="?android:attr/activatedBackgroundIndicator"

这行得通...有点不是我想要的,为一个文件创建一个新文件夹,但它可以工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-27
    • 2017-06-30
    • 1970-01-01
    相关资源
    最近更新 更多