java.lang.RuntimeException:无法启动活动 ComponentInfo{org.emphie.fod/org.emphie.fod.preferences}:android.view.InflateException:二进制 XML 文件第 7 行:膨胀类包含错误
我试图在支持它的版本中包含一个开关首选项,否则是一个复选框首选项。公平地说,我在 include 上找不到任何 docco,但我看到的示例都是针对布局的,而不是针对偏好的。
当只有某些元素需要不同的定义时,要求所有首选项片段为其适当的 API 完全定义似乎很疯狂。
屏幕:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:enabled="true" android:fragment="org.emphie.fod.preferences$prefFrag1" >
<PreferenceCategory android:title="Preferences" >
<include android:key = "@+id/send_sms" xml="@xml/pref_send_sms" />
</PreferenceCategory>
</PreferenceScreen>
包含的首选项:在 res-v14 中:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<SwitchPreference
android:defaultValue="true"
android:disableDependentsState="false"
android:key="@+id/send_SMS"
android:summaryOff="Just generate insults"
android:summaryOn="Actually send the wanker insults"
android:switchTextOff="No"
android:switchTextOn="Yes"
android:title="Send SMS" />
</merge>
在 res-v8 中
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<CheckBoxPreference
android:defaultValue="true"
android:disableDependentsState="false"
android:key="@+id/send_SMS"
android:summaryOff="Just generate insults"
android:summaryOn="Actually send the wanker insults"
android:switchTextOff="No"
android:switchTextOn="Yes"
android:title="Send SMS" />
</merge>
感谢您收到指向适当 docco 的链接,以及 google-fu 提示。我在做一些根本上、语法上或愚蠢的错误吗?