How to get an Android ListPreference defined in Xml whose values are integers?

后端 未结 3 871
北海茫月
北海茫月 2021-02-12 17:40

Is it possible to define a ListPreference in Xml and retrieve the value from SharedPreferences using getInt? Here is my Xml:



        
3条回答
  •  逝去的感伤
    2021-02-12 18:16

    In fact as you can read in the docs:

    http://developer.android.com/reference/android/preference/ListPreference.html#getValue()

    The method to get a ListPreference value is:

    public String getValue ()

    So you get a String. It's not a big deal, but could be prettier to admit integers.

提交回复
热议问题