开发者

Problem with catching Preference Item click event

开发者 https://www.devze.com 2023-02-24 09:49 出处:网络
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\' attri

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
    }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号