2

您好,我正在尝试在 actionbarsherlock 的任何地方使用 holoeeverywhere。

我的问题是在低 android 版本上(我在 SDK 8 上试过)我得到了奇怪的错误。

10-16 11:28:16.455: E/ResourceType(427): Style contains key with bad entry: 0x010102cd
10-16 11:28:16.455: E/ResourceType(427): Style contains key with bad entry: 0x010102dd
10-16 11:28:16.455: E/ResourceType(427): Style contains key with bad entry: 0x010102f0
10-16 11:28:16.455: E/ResourceType(427): Style contains key with bad entry: 0x010102cd
10-16 11:28:16.455: E/ResourceType(427): Style contains key with bad entry: 0x010102dd
10-16 11:28:16.455: E/ResourceType(427): Style contains key with bad entry: 0x010102f0
10-16 11:28:16.605: D/AndroidRuntime(427): Shutting down VM
10-16 11:28:16.605: W/dalvikvm(427): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-16 11:28:16.624: E/AndroidRuntime(427): FATAL EXCEPTION: main
10-16 11:28:16.624: E/AndroidRuntime(427): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.widget.ListView.measureScrapChild(ListView.java:1117)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.widget.ListView.measureHeightOfChildren(ListView.java:1200)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.widget.ListView.onMeasure(ListView.java:1109)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.View.measure(View.java:8171)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.widget.RelativeLayout.measureChild(RelativeLayout.java:563)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:378)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.View.measure(View.java:8171)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.View.measure(View.java:8171)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.View.measure(View.java:8171)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
10-16 11:28:16.624: E/AndroidRuntime(427):  at org.holoeverywhere.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:594)
10-16 11:28:16.624: E/AndroidRuntime(427):  at org.holoeverywhere.widget.LinearLayout.measureVertical(LinearLayout.java:913)
10-16 11:28:16.624: E/AndroidRuntime(427):  at org.holoeverywhere.widget.LinearLayout.onMeasure(LinearLayout.java:1105)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.View.measure(View.java:8171)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
10-16 11:28:16.624: E/AndroidRuntime(427):  at org.holoeverywhere.internal.WindowDecorView.onMeasure(WindowDecorView.java:114)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.View.measure(View.java:8171)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.View.measure(View.java:8171)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.View.measure(View.java:8171)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.os.Looper.loop(Looper.java:123)
10-16 11:28:16.624: E/AndroidRuntime(427):  at android.app.ActivityThread.main(ActivityThread.java:4627)
10-16 11:28:16.624: E/AndroidRuntime(427):  at java.lang.reflect.Method.invokeNative(Native Method)
10-16 11:28:16.624: E/AndroidRuntime(427):  at java.lang.reflect.Method.invoke(Method.java:521)
10-16 11:28:16.624: E/AndroidRuntime(427):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-16 11:28:16.624: E/AndroidRuntime(427):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-16 11:28:16.624: E/AndroidRuntime(427):  at dalvik.system.NativeStart.main(Native Method)

我的布局 XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background" >

    <TextView
        android:id="@+id/refreshText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="@color/white"
        android:gravity="center"
        android:text="Refreshing..."
        android:textColor="@color/Black"
        android:textSize="20sp"
        android:visibility="gone" />

    <com.example.workoutlog.WallScrollView
        android:id="@+id/wallList"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/refreshText"
        android:stackFromBottom="true"
        android:transcriptMode="alwaysScroll" >

        <LinearLayout
            android:id="@+id/workoutsWall"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
        </LinearLayout>
    </com.example.workoutlog.WallScrollView>

    <LinearLayout
        android:id="@+id/swipeLayOut2"
        android:layout_width="110sp"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="@color/Black"
        android:orientation="vertical"
        android:visibility="gone" >

        <Button
            android:id="@+id/goHomePage"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="home page"
            android:textColor="@color/Black"
            android:textSize="15sp" />

        <Button
            android:id="@+id/goCalendar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Calendar"
            android:textColor="@color/Black"
            android:textSize="15sp" />

        <Button
            android:id="@+id/goToday"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Today log"
            android:textColor="@color/Black"
            android:textSize="15sp" />

        <Button
            android:id="@+id/goLive"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="live workout"
            android:textColor="@color/Black"
            android:textSize="15sp" />

        <Button
            android:id="@+id/goRoutine"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Routines"
            android:textColor="@color/Black"
            android:textSize="15sp" />

        <Button
            android:id="@+id/goProgram"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Program plan"
            android:textColor="@color/Black"
            android:textSize="15sp" />

        <Button
            android:id="@+id/goPersonal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Pesonal detials"
            android:textColor="@color/Black"
            android:textSize="15sp" />

        <Button
            android:id="@+id/goWorkout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Set workout"
            android:textColor="@color/Black"
            android:textSize="15sp" />

        <Button
            android:id="@+id/goStatistics"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Statistics"
            android:textColor="@color/Black"
            android:textSize="15sp" />

        <Button
            android:id="@+id/goDiet"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Diet log"
            android:textColor="@color/Black"
            android:textSize="15sp" />
    </LinearLayout>

    <com.example.workoutlog.VerticalTextView
        android:id="@+id/swipeImage"
        android:layout_width="wrap_content"
        android:layout_height="63dp"
        android:layout_toRightOf="@+id/swipeLayOut2"
        android:background="@color/red"
        android:text="swipe right"
        android:textColor="@color/Black"
        android:textSize="18sp"
        android:visibility="gone" />

    <ProgressBar
        android:id="@+id/loadingProgress"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:indeterminateDrawable="@drawable/rotate_progress"
        android:visibility="gone" />

    <ImageButton
        android:id="@+id/fastUpWall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:visibility="gone"
        android:src="@drawable/fast_up" />

    <ImageButton
        android:id="@+id/fastDownWall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:visibility="gone"
        android:src="@drawable/fast_down" />

</RelativeLayout>

我不认为错误出现在 RelativeLayout$LayoutParams 部分,因为我什至在布局创建之前就收到了这个错误,甚至它的 RelativeLayout$LayoutParams 问题我也没有得到错误的任何行号,所以它真的很难跟踪。

我猜它与低 SDK 的风格有关。

感谢您的帮助。

4

1 回答 1

2

/这是因为您使用的主题属性在您运行应用程序的平台上不存在。较新的属性永远不会在较旧的平台上读取。使用更高的 sdk 版本,或删除此 sdk 版本不支持的样式中的属性。/

UPD:等等,可能问题不在于它。看这段代码: 10-16 11:28:16.624: E/AndroidRuntime(427): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams 这意味着布局参数必须是父级的类型. 因此,如果您要创建 RelativeLayout 并将其添加到 ListView,则布局参数必须是 ListView.LayoutParams 类型,而不是 RelativeLayout.LayoutParams。请把代码放在你在这一行的地方。

于 2013-10-16T11:39:33.947 回答