1
鉴于我res/xml/preferences.xml
看起来是这样的:ListPreference崩溃滚动时
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:orderingFromXml="true">
...
<PreferenceCategory android:title="@string/reminders">
<ListPreference
android:key="PREF_BATTERY_LOW"
android:title="@string/battery_low"
android:summary="@string/battery_low_desc"
android:entries="@array/battery_strings"
android:entryValues="@array/battery_values"
android:dialogTitle="@string/battery_low"
android:defaultValue="25"
/>
</PreferenceCategory>
...
</PreferenceScreen>
我激活一个SettingsActivity类这些首选项是这样的:
import android.preference.PreferenceActivity;
public class SettingsActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
的src/main/RES /价值/阵列。 XML是这样的:
<string-array name="battery_values">
<item>5</item>
<item>10</item>
<item>15</item>
<item>20</item>
<item>25</item>
<item>30</item>
<item>40</item>
<item>50</item>
</string-array>
<string-array name="battery_strings">
<item>5 %</item>
<item>10 %</item>
<item>15 %</item>
<item>20 %</item>
<item>25 %</item>
<item>30 %</item>
<item>40 %</item>
<item>50 %</item>
</string-array>
,当我使用SettingsActivity中,应用程序在打开页面时会一直崩溃。堆栈跟踪看起来是这样的:
E/InputEventReceiver(28227): Exception dispatching input event.
D/AndroidRuntime(28227): Shutting down VM
W/dalvikvm(28227): threadid=1: thread exiting with uncaught exception (group=0xa613b908)
I/AndroidRuntime(28227): VM exiting with result code 99, cleanup skipped.
I/ActivityManager( 432): Process com.company.app (pid 28227) has died.
D/dalvikvm(28249): Late-enabling CheckJNI
W/ActivityManager( 432): Scheduling restart of crashed service com.company.app/.services.LocationService in 5000ms
W/ActivityManager( 432): Force removing ActivityRecord{a6bfe408 u0 com.company.app/.SettingsActivity}: app died, no saved state
I/WindowState( 432): WIN DEATH: Window{a6cb7078 u0 com.company.app/com.company.app.main.MainActivity}
I/WindowState( 432): WIN DEATH: Window{a6cfea00 u0 com.company.app/com.company.app.SettingsActivity}
I/ActivityManager( 432): Start proc com.company.app for activity com.company.app/.main.MainActivity: pid=28249 uid=10064 gids={50064, 3003, 1028}
D/Zygote ( 160): Process 28227 exited cleanly (99)
E/Trace (28249): error opening trace file: No such file or directory (2)
E/jdwp (28249): Failed sending reply to debugger: Broken pipe
D/dalvikvm(28249): Debugger has detached; object registry had 1 entries
D/dalvikvm(28249): GC_FOR_ALLOC freed 126K, 2% free 8781K/8960K, paused 3ms, total 3ms
D/libEGL (28249): loaded /system/lib/egl/libEGL_emulation.so
D/ (28249): HostConnection::get() New Host Connection established 0xb78b4fd8, tid 28249
D/libEGL (28249): loaded /system/lib/egl/libGLESv1_CM_emulation.so
D/libEGL (28249): loaded /system/lib/egl/libGLESv2_emulation.so
W/EGL_emulation(28249): eglSurfaceAttrib not implemented
D/OpenGLRenderer(28249): Enabling debug mode 0
没有进一步的堆栈跟踪或任何其他有用的日志信息。 我一直在努力,以消除启动偏好(工程,但没有用),更改其类型(不支持)更改密钥&字符串类型,删除属性,但应用程序仍然崩溃。
往上几行我在使用其他ListPreference效果很好,仅这一个产生麻烦。我在这里错过了什么?
应该有更多的堆栈跟踪......如果你选择的logcat错误日志类型,它表现出更多? – gunar
日志从通过“亚行logcat”命令行来了。 –
的XML的根是不是'PreferenceCategory'任何机会?应该是'PreferenceScreen'。 – ozbek