Actually I just repeated what I was trying to do and realised I
phrased my question wrong.  What I meant was how do I get the selected
(localised) value - the code I quoted gets the key as you'd expect.


On Oct 2, 3:35 pm, Neil <neilb...@gmail.com> wrote:
> Yes I know that.  What I meant was that I can do this
>
> SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences
> (this);
> String value = pref.getString("key", "default value");
>
> And it will return the selected value.  But how do I get the selected
> key?
>
> On Oct 2, 2:06 pm, "Mark Murphy" <mmur...@commonsware.com> wrote:
>
> > > When using a PreferenceActivity to do preferences, the
> > > PreferenceScreen can contain a ListPreference.  A ListPreference has
> > > an array of keys and an array of values.  But the PreferenceActivity
> > > only writes the values to SharedPreferences.  How do I get the key of
> > > the item selected from the list?  I would have thought this is pretty
> > > fundamental, especially if you want to translate your app.
>
> > ListPreference takes two string arrays. The first string array is what the
> > user sees, and that you would localize. The second string array is what
> > gets stored in the SharedPreferences, and that you would not localize.
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com
> > Android App Developer Books:http://commonsware.com/books.html
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to