Change the summary of a ListPreference with the new value (Android)

前端 未结 14 1129
感动是毒
感动是毒 2020-12-30 03:01

How can I modify the summary of a ListPreference to the new \"Entry\" string selected by the user (not the entry value)

I suppouse its with setOnPreferenceChangeList

14条回答
  •  梦毁少年i
    2020-12-30 04:06

    Hi edited the above for EditText if that helps :)

    package fr.bmigette.crocoschedulerconsoleandroid;
    import android.content.Context;
    import android.preference.EditTextPreference;
    import android.util.AttributeSet;
    
    /**
     * Created by bastien on 28/07/2015.
     */
    public class EditTextPreferenceWithSummary extends EditTextPreference{
        public EditTextPreferenceWithSummary(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public EditTextPreferenceWithSummary(Context context) {
            super(context);
        }
    
        @Override
        public void setText(String value) {
            super.setText(value);
            setSummary(value);
        }
    
        @Override
        public void setSummary(CharSequence summary) {
            super.setSummary(getText());
        }
    }
    

    And creates the preference.xml like this:

    
    
    
        
            
    
            
    
            
    
        
    
    

提交回复
热议问题