Where to store Android preference keys?

前端 未结 7 1035
孤城傲影
孤城傲影 2020-12-23 11:33

When I create preference activity I define all preferences in xml file. Every preference has a key defined in this xml. But when I access preference I write:



        
7条回答
  •  情话喂你
    2020-12-23 11:54

    I've found that it's possible to store keys in strings.xml and refer to them from preferences.xml just like all other values android:key="@string/preference_enable".

    In code you can refer to key by typing getString(R.string.preference_enable)

    You can mark the string to not be translated using a tag. See Localization Checklist

    enable
    

提交回复
热议问题