我创建了一个PreferenceScreen
,效果非常好,但我最近添加了两个EditTextPreferences
,似乎有些不对劲。只要单击EditTextPreference
,应用程序就会崩溃。
这是我的 preferences.xml :
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/title_telephone">
<SwitchPreference
android:defaultValue="@string/default_checkbox_telephone_recording"
android:key="checkbox_preference_telephone_recording"
android:summary="@string/preference_recording_summary"
android:title="@string/checkbox_telephone_recording" />
<SwitchPreference
android:defaultValue="@string/default_checkbox_telephone_accel"
android:key="checkbox_preference_telephone_accel"
android:summary="@string/preference_accel_summary"
android:title="@string/checkbox_telephone_accel" />
</PreferenceCategory>
<PreferenceCategory android:title="Allgemeine Informationen">
<EditTextPreference
android:defaultValue="none"
android:clickable="false"
android:key="textfield_preference_client_ID"
android:title="@string/textbox_client_ID_title"
android:summary="0" />
<EditTextPreference
android:defaultValue="none"
android:clickable="false"
android:key="textfield_preference_version_ID"
android:title="@string/textbox_version_ID_title"
android:summary="@string/version_ID" />
</PreferenceCategory>
</PreferenceScreen>
以下是 stacktrace :
Process: com.applications.philipp.apkinson, PID: 13798
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1307)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2871)
at android.content.res.Resources.getLayout(Resources.java:1123)
at android.view.LayoutInflater.inflate(LayoutInflater.java:412)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatDialog.setContentView(AppCompatDialog.java:80)
at android.support.v7.app.AlertController.installContent(AlertController.java:214)
at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:256)
at android.app.Dialog.dispatchOnCreate(Dialog.java:381)
at android.app.Dialog.show(Dialog.java:282)
at android.support.v4.app.DialogFragment.onStart(DialogFragment.java:406)
at android.support.v4.app.Fragment.performStart(Fragment.java:2000)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1102)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5373)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
有人可以帮我这个吗?我没有设法解决这个问题。我希望EditTextPreferences
不可点击,但我尝试了没有这个xml参数,它会崩溃。
更新
当我用EditTextPreference
替换Preference
时,一切都很有效。但是,这并没有真正解释为什么我的配置遇到了麻烦。
答案 0 :(得分:0)
那里的问题因为您尝试将链接放在不存在的资源上。这里可能有问题:android:summary =“0”。尝试在值为“0”的@string资源上更改它