Problem with catching Preference Item click event
I'm building an android application and I have a pretty dumb question -
I've created a preference screen and put in it a list and a checkBox. Now I handled those just fine, using the 'key' attribute that is saved automatically.
My problem comes when I try using a si开发者_开发技巧mple Preference Item(they type that you just press it).
What is saved in SharedPreference
when it's clicked? If nothing, how can I catch the click event?
I can't find an answer anywhere. Thanks a lot!
tofira,
You need to use setOnPreferenceClickListener()
for that particular item. See example:
Preference myPref = (Preference) findPreference("myPref");
myPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
//handle action on click here
}
});
精彩评论