开发者

How to bind Preferences with List

开发者 https://www.devze.com 2023-04-10 17:15 出处:网络
I think I read this somewhere, but I can\'t seem to find it anymore. Is there a way to bind preferences with a Lis开发者_JAVA百科tView so that onListItemClick, so I can edit or delete the preference

I think I read this somewhere, but I can't seem to find it anymore.

Is there a way to bind preferences with a Lis开发者_JAVA百科tView so that onListItemClick, so I can edit or delete the preference without having to do the bookkeeping myself?


You don't need to use ListView for this. Assuming its done from within PreferenceActivity

//setting the click listener
Preference somePref = getPreferenceScreen().findPreference("preference");
somePref.setOnPreferenceClickListener(new OnPreferenceClickListener() {            
    @Override
    public boolean onPreferenceClick(Preference preference) {
        getPreferenceScreen().removePreference(preference);            
        return true;
    }
});


PreferenceActivity sounds like what you want. I don't know why you'd want to 'delete' a preference though.

0

精彩评论

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

关注公众号