Question

How can I display the seekbar value using a SeekBarPreference?

<PreferenceCategory 
     android:title="Delay between change image">

     <SeekBarPreference
         android:id="@+id/preference_delay_seek_bar"
         android:title="Value"
         android:defaultValue="1"
         android:max="60"/>

</PreferenceCategory>
Was it helpful?

Solution 2

Something like this:

((SeekBarPreference) findPreference(R.id.preference_delay_seek_bar)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
  @Override
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    final int progress = Integer.valueOf(String.valueOf(newValue));
    preference.setSummary(String.format("My progress value: %d", progress));
  }
});

OTHER TIPS

With JetPack I could simply add the following attribute to the SeekBarPreference XML element.

app:showSeekBarValue="true"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top