MultiSelectListPreference上的错误

时间:2013-11-24 08:24:28

标签: android multiselectlistpreference

您好我想问为什么我的MultiSelectListPreference在这里收到错误是我的代码

XML>的prefs.xml

<MultiSelectListPreference
    android:title="MultiSelectList"
    android:key="multi"
    android:summary="List to choose from"
    android:entries="@array/MultiSelectList"
    android:entryValues="@array/mlValues"
    android:defaultValue="@array/empty_array"
    >
</MultiSelectListPreference>

值&GT; array.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

<string-array name="MultiSelectList">
    <item>Option1</item>
    <item>Option2</item>
    <item>Option3</item>
    <item>Option4</item> 
</string-array>

<string-array name="mlValues">
    <item>1</item>
    <item>2</item>
    <item>3</item>
    <item>4</item>
</string-array>

<string-array name="empty_array">
    <item>0</item>
    <item>0</item>
    <item>0</item>
    <item>0</item>
</string-array>

</resources>

但是当我将MultiSelectListPreference更改为ListPreference它工作正常请帮我解决这个问题

这是我的 logcat

10-18 20:52:59.354: D/AndroidRuntime(6432): Shutting down VM
10-18 20:52:59.354: W/dalvikvm(6432): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-18 20:52:59.385: E/AndroidRuntime(6432): FATAL EXCEPTION: main
10-18 20:52:59.385: E/AndroidRuntime(6432): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thesis.logipic/com.thesis.logipic.Prefs}: android.view.InflateException: Binary XML file line #11: Error inflating class MultiSelectListPreference
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.os.Looper.loop(Looper.java:123)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.app.ActivityThread.main(ActivityThread.java:4627)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at java.lang.reflect.Method.invokeNative(Native Method)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at java.lang.reflect.Method.invoke(Method.java:521)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at dalvik.system.NativeStart.main(Native Method)
10-18 20:52:59.385: E/AndroidRuntime(6432): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class MultiSelectListPreference
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:441)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.preference.GenericInflater.inflate(GenericInflater.java:326)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.preference.GenericInflater.inflate(GenericInflater.java:263)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:251)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:262)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at com.thesis.logipic.Prefs.onCreate(Prefs.java:12)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
10-18 20:52:59.385: E/AndroidRuntime(6432):     ... 11 more
10-18 20:52:59.385: E/AndroidRuntime(6432): Caused by: java.lang.ClassNotFoundException: android.preference.MultiSelectListPreference in loader dalvik.system.PathClassLoader[/data/app/com.thesis.logipic-2.apk]
10-18 20:52:59.385: E/AndroidRuntime(6432):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.preference.GenericInflater.createItem(GenericInflater.java:375)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.preference.GenericInflater.onCreateItem(GenericInflater.java:417)
10-18 20:52:59.385: E/AndroidRuntime(6432):     at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:428)
10-18 20:52:59.385: E/AndroidRuntime(6432):     ... 19 more
10-18 20:52:59.486: D/dalvikvm(6432): GC_FOR_MALLOC freed 2782 objects / 218152 bytes in 87ms
10-18 20:53:01.565: I/Process(6432): Sending signal. PID: 6432 SIG: 9

Prefs.java

public class Prefs extends PreferenceActivity{

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.prefs);
}


}

0 个答案:

没有答案