开发者

Creating a ListPreference options menu

开发者 https://www.devze.com 2023-04-12 22:14 出处:网络
I\'m trying to create an option menu in my preferences but I can\'t get the options to display. When I select the option in the prefs menu I got an empty pop up dialog (title at the top, button at the

I'm trying to create an option menu in my preferences but I can't get the options to display. When I select the option in the prefs menu I got an empty pop up dialog (title at the top, button at the bottom, but no options).

This is what I do: I create an array.xml file in re开发者_JS百科s/values

<?xml version="1.0" encoding="utf-8"?>
 <resources>
 <string-array name="listArray">
 <item>3</item>
 <item>5</item>
 <item>7</item>
 <item>10</item>
 <item>15</item>
 <item>20</item>
 </string-array>

<string-array name="listValues">
 <item>3</item>
 <item>5</item>
 <item>7</item>
 <item>10</item>
 <item>15</item>
 <item>20</item>
</string-array>   

and in m prefs.xml i have:

<ListPreference 
    android:dialogTitle="@string/prefsMaxAdAge"
    android:dialogMessage="@string/prefsMaxAdAgeSummary" 
    android:key="itemMaxAdAge"
    android:title="@string/prefsMaxAdAge" 
    android:summary="@string/prefsMaxAdAgeSummary"
    android:entryValues="@array/listValues" 
    android:entries="@array/listArray">
</ListPreference>

Any help would be much appreciated! Thank you!


I finally found the solution to that problem. The XML field DialogMsg must not be set. This makes sense after all. Useful help was found here: http://code.google.com/p/android/issues/detail?id=4497


ListPreferences seem to appear empty whenever they contain a dialogMessage. As to why, I would very much like to know the answer...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号