朋友, 我正在使用以下xml实际上我想绘制图像以及文本框然后等控制上面然后prefrences这就是为什么在根级使用relativelayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_height="fill_parent" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="First Category">
<ListPreference
android:title="List Preference"
android:summary="This preference allows to select an item in a array"
android:key="listPref"
android:defaultValue="digiGreen"
android:entries="@array/justforme_title_array"
android:entryValues="@array/sub_justforme_array" />
</PreferenceCategory>
</PreferenceScreen>
</RelativeLayout>
和java代码
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.justforme);
}
它给了我以下错误
01-20 15:07:54.412: ERROR/AndroidRuntime(648): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.abc/com.abc.JustForMe}: android.view.InflateException: Binary XML file line #3: Error inflating class PreferenceScreen
任何帮助将不胜感激。
答案 0 :(得分:0)
我认为PreferenceScreen
必须位于xml文件的顶部。您无需将其封装到布局中。
尝试删除ralativelayout:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="First Category">
<ListPreference
android:title="List Preference"
android:summary="This preference allows to select an item in a array"
android:key="listPref"
android:defaultValue="digiGreen"
android:entries="@array/justforme_title_array"
android:entryValues="@array/sub_justforme_array" />
</PreferenceCategory>
</PreferenceScreen>
答案 1 :(得分:0)
我认为你的代码中的问题就是你在根级别使用相对布局。可能来自这两个方面对你有用:一次只能尝试一个。
1 :)从root中删除相对layotu,ramainig代码与你粘贴的相同。
2 :)删除:来自preferencescreen标签的xmlns:属性。