Code example for Preference

Methods: setSummary

                ListPreference listPreference = (ListPreference) preference; 
                String stringValue = newValue.toString(); 
                int index = listPreference.findIndexOfValue(stringValue); 
                // Set the summary to reflect the new value. 
                        index >= 0 
                                ? (listPreference.getEntries()[index]) 
                                        .toString().replaceAll("%", "%%") 
                                : null); 
            return true; 
     * Binds a preference's summary to its value. More specifically, when the 
     * preference's value is changed, its summary (line of text below the 
     * preference title) is updated to reflect the value. The summary is also 
     * immediately updated upon calling this method. The exact display format is 
Contextual code suggestions in your IDE  Get Codota for Java