首选项ListView不会填充

时间:2012-03-01 17:21:31

标签: android android-listview android-preferences

我的自定义Preference包含ListView。我想在PreferenceActivity中显示它(在同一个屏幕中不在Diaog中),但它不会填充。我告诉你da代码,哈哈。我的ListPreferences对象它只是一个从Preference

延伸的对象

PreferenceActivity:

公共类SettingsActivity扩展了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>

list_preference.xml

<?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>

0 个答案:

没有答案