The problem with trapping.

I am creating an Android app and I have a pretty dumb question -

I created a settings screen and entered a list and checkBox into it. Now I did a great job with them using the key attribute, which is automatically saved.

My problem arises when I try to use a simple preference item (they type that you just click on it). What is saved in SharedPreference when clicked? If nothing, how can I catch the click event?

I can not find the answer anywhere. Thank you very much!

+4
source share
1 answer

tofira,

You need to use setOnPreferenceClickListener() for this particular element. Example:

 Preference myPref = (Preference) findPreference("myPref"); myPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { //handle action on click here } }); 
+12
source

Source: https://habr.com/ru/post/1347591/


All Articles