开发者

Reacting to a click on a preference

I have a simple preference (not EditText preference or ListPreference). I have a method that deletes all files开发者_运维问答 in a directory. I want to do this when user clicks on a preference, but i don't know how to react to a click on a preference.


getPreferenceManager().findPreference("pref_key").setOnPreferenceClickListener(new OnPreferenceClickListener()
{
    @Override
    public boolean onPreferenceClick(Preference preference)
    {
        // Do stuff here
    }
});


if your preference is stored in an object(togglePref) you can do this

togglePref.setOnPreferenceClickListener(this);

then the event is:

@Override
public boolean onPreferenceClick(Preference preference) {

}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜