1

我有一个奇怪的问题,如果我尝试将 Drawable xml 文件分配给布局文件,那么应用程序就会崩溃。但是,如果我改用标准颜色代码,它就可以正常工作。

笔记。我几乎使用新的模板 Master/Detail Flow,我还在基本布局的 Root 视图上分配了一个 xml drawable,它工作正常。问题是将 Drawable xml 分配到列表片段的布局 (list_content.xml)

这是我的背景 xml

<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
    android:startColor="#FF000000"
    android:endColor="#FF555555"
    android:type="linear"
    />
</shape>

我的布局是

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:background="@drawable/background_lhs"
    >

<LinearLayout android:id="@+id/progressContainer"
        android:orientation="vertical"
        android:layout_width="match_parent" 
        android:layout_height="match_parent"
        android:visibility="gone"
        android:gravity="center" >

    <ProgressBar style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="Loading"
            android:paddingTop="4dip"
            android:singleLine="true" />

</LinearLayout>

<FrameLayout android:id="@+id/listContainer"
        android:layout_width="match_parent" 
        android:layout_height="match_parent"

        >

    <ListView android:id="@android:id/list"
            android:layout_width="match_parent" 
            android:layout_height="match_parent"
            android:drawSelectorOnTop="false" 

            />
    <TextView android:id="@+id/internalEmpty"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:textAppearance="?android:attr/textAppearanceLarge" />
</FrameLayout>

</FrameLayout>

^ 在最顶部,您会找到backgrounds参考,当我将其更改为正常值(例如#000000)时,它就起作用了。我也尝试过在drawable xml中使用纯色作为形状,但仍然会导致崩溃。原木猫除了没有什么帮助外Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1), thread 2521。没有明显的迹象可以告诉我 logcat 有什么问题,也没有内存警告或错误。

这是请求的logcat

05-04 07:03:58.510: D/dalvikvm(1718): Not late-enabling CheckJNI (already on)
05-04 07:03:58.520: E/Trace(1718): error opening trace file: No such file or directory (2)
05-04 07:03:58.520: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:03:58.520: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:03:58.520: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:03:58.520: W/ActivityThread(1718): Application com.td3.testapp is waiting for the debugger on port 8100...
05-04 07:03:58.520: I/System.out(1718): Sending WAIT chunk
05-04 07:03:59.173: I/dalvikvm(1718): Debugger is active
05-04 07:03:59.350: I/System.out(1718): Debugger has connected
05-04 07:03:59.350: I/System.out(1718): waiting for debugger to settle...
05-04 07:03:59.560: I/System.out(1718): waiting for debugger to settle...
05-04 07:03:59.764: I/System.out(1718): waiting for debugger to settle...
05-04 07:03:59.970: I/System.out(1718): waiting for debugger to settle...
05-04 07:04:00.173: I/System.out(1718): waiting for debugger to settle...
05-04 07:04:00.383: I/System.out(1718): waiting for debugger to settle...
05-04 07:04:00.594: I/System.out(1718): waiting for debugger to settle...
05-04 07:04:00.800: I/System.out(1718): waiting for debugger to settle...
05-04 07:04:01.013: I/System.out(1718): debugger has settled (1362)
05-04 07:04:01.013: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.013: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.040: D/dalvikvm(1718): GC_FOR_ALLOC freed 94K, 8% free 2508K/2720K, paused 1ms, total 2ms
05-04 07:04:01.071: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.090: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.100: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.100: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.120: D/libEGL(1718): loaded /system/lib/egl/libEGL_emulation.so
05-04 07:04:01.120: D/(1718): HostConnection::get() New Host Connection established 0xb9518330, tid 1718
05-04 07:04:01.140: D/libEGL(1718): loaded /system/lib/egl/libGLESv1_CM_emulation.so
05-04 07:04:01.140: D/libEGL(1718): loaded /system/lib/egl/libGLESv2_emulation.so
05-04 07:04:01.201: W/EGL_emulation(1718): eglSurfaceAttrib not implemented
05-04 07:04:01.220: D/OpenGLRenderer(1718): Enabling debug mode 0
05-04 07:04:01.220: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.231: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.231: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.231: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.231: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.241: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.241: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.241: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.241: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.241: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.241: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.251: A/libc(1718): Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1), thread        1718 (.td3.testapp)
4

1 回答 1

0

在偶然发现本网站的另一个问题后,关于“打开跟踪文件时出错:没有这样的文件或目录 (2)”,那里的答案似乎意外地解决了我的问题。我评论的那一刻 <uses-sdk /> 突然开始工作,然后即使我删除了该评论,它仍然可以工作,所以我不知道这是一个错误还是以某种方式重置了某些东西,但除了解决这个问题我什么也没做我的问题。

于 2013-05-06T04:31:36.977 回答