Code example for PreferenceScreen

Methods: findPreference

     * @param fieldName the preference key name 
    public void setListFieldSummary(String fieldName) {
        PreferenceScreen pfs = getPreferenceScreen();
        ListPreference pref = (ListPreference) pfs.findPreference(fieldName);
        CharSequence val = pref.getEntry();
        if (TextUtils.isEmpty(val)) {
            val = getDefaultFieldSummary(fieldName);
        setPreferenceSummary(pref, val);
     * Safe setSummary on a Preference object that make sure that the preference 
     * exists before doing anything 
     * @param pref the preference to change summary of 
     * @param val the string to set as preference summary 
Experience pair programming with AI  Get Codota for Java