Non Deprecated findPreference() Method? - Android

前端 未结 4 1422
梦毁少年i
梦毁少年i 2020-12-02 20:22

I want to detect when a Preference contained in a ListView gets clicked, so that I can launch an intent to manage that selection.

I would h

4条回答
  •  长情又很酷
    2020-12-02 20:35

    2018 UPDATE Today, the onPreferenceTreeClick method has to be overriden in the Preference fragment for this purpose. For example:

    public class MySettingsFragment extends PreferenceFragment {
    
        @Override
        public boolean onPreferenceTreeClick (PreferenceScreen preferenceScreen,
                                              Preference preference)
        {
            String key = preference.getKey();
            if(key.equals("someKey")){
                // do your work
                return true;
            }
            return false;
        }
    }
    

提交回复
热议问题