Android 首选项列表视图没有';t填充
我有一个自定义的Android 首选项列表视图没有';t填充,android,android-listview,android-preferences,Android,Android Listview,Android Preferences,我有一个自定义的首选项,包含在列表视图中。我想在首选项活动中显示它(在同一屏幕中而不是在Diaog中),但它不会填充。我给你看da代码,lol。我的ListPreferences对象它只是一个从首选项扩展而来的对象 优惠活动: 公共类设置活动扩展了PreferenceActivity{ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPrefe
首选项
,包含在列表视图中
。我想在首选项活动
中显示它(在同一屏幕中而不是在Diaog
中),但它不会填充。我给你看da代码,lol。我的ListPreferences对象它只是一个从首选项扩展而来的对象
优惠活动:
公共类设置活动扩展了PreferenceActivity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
preference.xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:key="themeTitle"
android:title="@string/settings_group_themes">
<com.battleship.preferences.ListPreferences
android:key="theme" android:widgetLayout="@id/listView" />
</PreferenceCategory>
</PreferenceScreen>
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listView" android:layout_width="wrap_content"
android:choiceMode="singleChoice" android:layout_height="wrap_content"
android:orientation="vertical" android:footerDividersEnabled="true"
android:entries = "@array/themeArray"
/>
list_preference.xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:key="themeTitle"
android:title="@string/settings_group_themes">
<com.battleship.preferences.ListPreferences
android:key="theme" android:widgetLayout="@id/listView" />
</PreferenceCategory>
</PreferenceScreen>
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listView" android:layout_width="wrap_content"
android:choiceMode="singleChoice" android:layout_height="wrap_content"
android:orientation="vertical" android:footerDividersEnabled="true"
android:entries = "@array/themeArray"
/>
arrays.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="themeArray">
<item>Default</item>
<item>Black</item>
<item>White</item>
</string-array>
</resources>
违约
黑色
白色
不确定问题出在哪里。通读一遍:我的问题是这个。我想显示我的自定义首选项,它是一个ListView,但它没有填充我提供的数据。*我没有看到您在任何地方用数据填充ListView。此外,属性android:widgetLayout=“
不用于替换对话框;使用android:dialogLayout=“”
。