I have a settings menu that pops up and in it is a ListPreference type menu. It is associated with a settings.xml file where there are ‘array-strings’ within it. It all works good but I don’t know how to retrieve the users preference.
As an example, let’s say the user picks a color (red, green, or blue). The list that I’ve made within my ‘array-strings’ contain the text red, green, and blue. Within my code, I would like to do something if the user has chosen red, something else if they choose blue, etc., etc. Would I use a ‘case’ statement or an ‘if’ statement? And most importantly, how would I retrieve the users preference – the key? (am I checking for a boolean?)
If you are using ListPreference and you haven’t disabled Persistent state, you can read the selected value from the SharedPreferences, after the setting is completed.
Also you can subscribe to
onClickevent, and you use the code Rpond mentioned.