2013-04-10 47 views
1

我從網站上下載的代碼:http://blog.350nice.com/wp/archives/240如何設置PreferenceScreen的xmlns路徑修改ListPreferenceMultiSelect

但是就行了:

<com.threefiftynice.android.preference.ListPreferenceMultiSelect 

是錯誤代碼:

Multiple annotations found at this line: 
    - error: No resource identifier found for attribute 'checkAll' in package 
    'com.threefiftynice.android' 
    - error: No resource identifier found for attribute 'separator' in package 
    'com.threefiftynice.android' 

這是XML錯誤:

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen android:key="prefKey" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:threefiftyprefs="http://schemas.android.com/apk/res/com.threefiftynice.android"> 
    <com.threefiftynice.android.preference.ListPreferenceMultiSelect 
     threefiftyprefs:checkAll="check" threefiftyprefs:separator="|" 
     android:defaultValue="#ALL#" 
     android:key="key" 
     android:title="Image folders to monitor" android:dialogTitle="Image folders to monitor" 
     android:summary="Specify which folders should be monitored for images" 
     android:entries="@array/typeOfPoints" 
     android:entryValues="@array/typeOfPointsID"/> 
</PreferenceScreen> 

我知道xmlns和ListPreferenceMultiselect的路徑很糟糕 - 但我嘗試了很多可能的路徑,並且問題出現在所有這些路徑中(這是網站原始路徑的原始路徑)。這是我的代碼

的結構: enter image description here

我應該怎樣設置路徑,使其工作?非常感謝你。

編輯: 它chanded到xmlns:threefiftyprefs="schemas.android.com/apk/res-auto"後,它不會在XML寫錯誤,但它在運行拋出錯誤:

Uncaught handler: thread main exiting due to uncaught exception
java.lang.RuntimeException: Unable to start activity ComponentInfo{goandknow.proximityalerts/goandknow.proximityalerts.EditPreferences}: android.view.InflateException: Binary XML file line #24: Error inflating class com.threefiftynice.android.preference.ListPreferenceMultiSelect at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284) at android.app.ActivityThread.access$1800(ActivityThread.java:112)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:3948) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #24: Error inflating class com.threefiftynice.android.preference.ListPreferenceMultiSelect at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:441) at android.preference.GenericInflater.rInflate(GenericInflater.java:481) at android.preference.GenericInflater.rInflate(GenericInflater.java:493) at android.preference.GenericInflater.inflate(GenericInflater.java:326)
at android.preference.GenericInflater.inflate(GenericInflater.java:263)
at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:250) at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:253) at goandknow.proximityalerts.EditPreferences.onCreate(EditPreferences.java:24) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231) ... 11 more

這是第24行:

com.threefiftynice.android.preference.ListPreferenceMultiSelect

+1

嘗試改變線的xmlns:threefiftyprefs = 「http://schemas.android.com/apk/res/com.threefiftynice.android」 到的xmlns:threefiftyprefs =「http://schemas.android.com/apk/res-汽車「 – 2013-04-10 12:00:49

+0

非常感謝你的幫助 - 但現在當我嘗試在代碼中運行它時出現錯誤。我張貼的logcat的輸出 - 你不知道什麼可能是錯誤的 - 'com.threefiftynice.android.preference.ListPreferenceMultiSelect'這是確定? – Tunerx 2013-04-10 12:14:53

+0

嘗試清理您的項目 – 2013-04-10 12:34:25

回答

1

更改的行

xmlns:threefiftyprefs="http://schemas.android.com/apk/res/com.threefiftynice.android"

xmlns:threefiftyprefs="http://schemas.android.com/apk/res-auto"

0

這是應該的:

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen android:key="prefKey" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:threefiftyprefs="schemas.android.com/apk/res-auto"> 
    <goandknow.models.ListPreferenceMultiSelect 
    threefiftyprefs:checkAll="check" threefiftyprefs:separator="|" 
    android:defaultValue="#ALL#" 
    android:key="key" 
    android:title="Image folders to monitor" android:dialogTitle="Image folders" 
    android:summary="Specify which folders should be monitored for images" 
    android:entries="@array/typeOfPoints" 
    android:entryValues="@array/typeOfPointsID"/> 
</PreferenceScreen> 

重要:

的xmlns:threefiftyprefs =「schemas.android.com/apk/res-auto 「 goandknow.models.ListPreferenceMultiSelect由於桑卡爾五