1

您好我正在尝试使用 holoeverwhere 使我的应用程序向后兼容。在我的应用程序中,我有一个选项卡活动和 3 个 holoeverywhere 活动。当我在 2.3.3 模拟器上运行我的应用程序时,它会运行并显示我的第一个选项卡,但如果我切换到第二个或第三个选项卡,它会意外关闭。错误发生在我的 setContentView 行的第二个或第三个选项卡中。该错误不是由切换选项卡引起的,因为如果我在默认情况下在第二个选项卡上启动应用程序,我仍然会收到相同的错误。如果我在 4.1.2 设备上运行我的应用程序,那么它工作得很好。

这是我的日志猫

12-26 13:33:03.511: E/AndroidRuntime(744): FATAL EXCEPTION: main
12-26 13:33:03.511: E/AndroidRuntime(744): java.lang.RuntimeException: Unable to start            activity ComponentInfo{com.chair49.holotimer/com.chair49.holotimer.StopWatch}:         android.view.InflateException: Binary XML file line #20: Error inflating class android.view.View
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.app.ActivityThread.startActivityNow(ActivityThread.java:1487)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:654)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.widget.TabHost.setCurrentTab(TabHost.java:326)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:132)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:456)
12-26 13:33:03.511: E/AndroidRuntime(744):  at  android.view.View.performClick(View.java:2485)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.View$PerformClick.run(View.java:9080)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.os.Handler.handleCallback(Handler.java:587)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.os.Handler.dispatchMessage(Handler.java:92)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.os.Looper.loop(Looper.java:123)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.app.ActivityThread.main(ActivityThread.java:3683)
12-26 13:33:03.511: E/AndroidRuntime(744):  at java.lang.reflect.Method.invokeNative(Native Method)
12-26 13:33:03.511: E/AndroidRuntime(744):  at java.lang.reflect.Method.invoke(Method.java:507)
12-26 13:33:03.511: E/AndroidRuntime(744):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-26 13:33:03.511: E/AndroidRuntime(744):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-26 13:33:03.511: E/AndroidRuntime(744):  at dalvik.system.NativeStart.main(Native Method)
12-26 13:33:03.511: E/AndroidRuntime(744): Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class android.view.View
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.LayoutInflater.createView(LayoutInflater.java:518)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
12-26 13:33:03.511: E/AndroidRuntime(744):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
12-26 13:33:03.511: E/AndroidRuntime(744):  at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
12-26 13:33:03.511: E/AndroidRuntime(744):  at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
12-26 13:33:03.511: E/AndroidRuntime(744):  at com.chair49.holotimer.StopWatch.onCreate(StopWatch.java:49)  // this is my setcontentview line
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
12-26 13:33:03.511: E/AndroidRuntime(744):  ... 18 more
12-26 13:33:03.511: E/AndroidRuntime(744): Caused by: java.lang.reflect.InvocationTargetException
12-26 13:33:03.511: E/AndroidRuntime(744):  at java.lang.reflect.Constructor.constructNative(Native Method)
12-26 13:33:03.511: E/AndroidRuntime(744):  at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.LayoutInflater.createView(LayoutInflater.java:505)
12-26 13:33:03.511: E/AndroidRuntime(744):  ... 32 more
12-26 13:33:03.511: E/AndroidRuntime(744): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x101030a a=-1}
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.content.res.Resources.loadDrawable(Resources.java:1681)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.View.<init>(View.java:1951)
12-26 13:33:03.511: E/AndroidRuntime(744):  at android.view.View.<init>(View.java:1899)
12-26 13:33:03.511: E/AndroidRuntime(744):  ... 35 more

这是我的第三个选项卡的 xml

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

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_weight="50"
    android:gravity="bottom"
    android:weightSum="100">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_alignParentBottom="true" >

        <View
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="1dip"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="4dip"
            android:layout_marginRight="4dip"
            android:background="?android:attr/android:dividerVertical" />

        <View
            android:id="@+id/ViewColorPickerHelper"
            android:layout_width="1dip"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="4dip"
            android:layout_marginTop="4dip"
            android:background="?android:attr/android:dividerVertical" />

        <org.holoeverywhere.widget.Button
            android:id="@+id/bStart"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/view1"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/ViewColorPickerHelper"
             style="@style/Holo.Button.Borderless"
            android:text="Start" />

        <org.holoeverywhere.widget.Button
            android:id="@+id/bStop"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:layout_alignRight="@+id/view1"
            android:layout_toRightOf="@+id/ViewColorPickerHelper"
             style="@style/Holo.Button.Borderless"
            android:text="Stop" />
    </RelativeLayout>
</LinearLayout>

<Chronometer
    android:id="@+id/chronometer2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:text="Chronometer"
    android:textSize="0px"
    android:visibility="invisible" />

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="56dp" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ImageButton
            android:id="@+id/hourup"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             style="@style/Holo.Button.Borderless"
            android:clickable="false"
            android:src="@drawable/up"
            android:visibility="invisible" />

        <ImageButton
            android:id="@+id/minuteup"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             style="@style/Holo.Button.Borderless"
            android:clickable="false"
            android:src="@drawable/up"
            android:visibility="invisible" />

        <ImageButton
            android:id="@+id/secondup"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/Holo.Button.Borderless"
            android:clickable="false"
            android:src="@drawable/up"
            android:visibility="invisible" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <org.holoeverywhere.widget.TextView
            android:id="@+id/hour"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="00 : "
            android:textSize="35sp" />

        <org.holoeverywhere.widget.TextView
            android:id="@+id/minute"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="00 : "
            android:textSize="35sp" />

        <org.holoeverywhere.widget.TextView
            android:id="@+id/second"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="00"
            android:textSize="35sp" />

        <org.holoeverywhere.widget.TextView
            android:id="@+id/ending"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="58dp"
            android:text=".000" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ImageButton
            android:id="@+id/hourdown"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/Holo.Button.Borderless"
            android:clickable="false"
            android:src="@drawable/down"
            android:visibility="invisible" />

        <ImageButton
            android:id="@+id/minutedown"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/Holo.Button.Borderless"
            android:clickable="false"
            android:src="@drawable/down"
            android:visibility="invisible" />

        <ImageButton
            android:id="@+id/seconddown"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/Holo.Button.Borderless"
            android:clickable="false"
            android:src="@drawable/down"
            android:visibility="invisible" />
    </TableRow>
</TableLayout>

4

1 回答 1

1

?android:attr/android:dividerVertical

它是什么?

?dividerVertical

它:style="@style/Holo.Button.Borderless"
对:style="?borderlessButtonStyle"

它:<org.holoeverywhere.widget.TextView />
<TextView />没用?

于 2012-12-27T06:25:48.827 回答