I'm writing my first Android app and it involves a preference where you set an amount of minutes, from 0 to 60. I've used a SeekBarPreference, and it shows up as a simple slider which you can indeed slide around to edit the value. The preference works fine.
I would like to show the selected value next to the SeekBar (or somewhere in the vicinity), as there by default is no way for the user to see what they've actually selected. There are lots of questions on Stack Overflow about similar sliders and preferences, but since version 25.1.0, released last December, there is SeekBarPreference, which has just what I need:
The seekbar value view can be shown or disabled by setting
showSeekBarValueattribute to true or false, respectively.
But among the public methods listed below, there is no method for setting showSeekBarValue? There is a method for setting the adjustable attribute, setAdjustable(boolean adjustable), however?
Ideally I'd just write android:showSeekBarValue="true" in my SeekBarPreference tag in preferences.xml, but that (obviously) doesn't work.
So in a nutshell: how do I set showSeekBarValue to true?
In the app's build.gradle, I had to add
Then, modify the PreferenceScreen's xml to include an app namespace:
Finally, inside the xml, you can add
This compiles without errors. To be fair, this is not a complete answer, because no value is shown in my case, even after these steps. But formally it does let you set the value in some way.