I'm using SeekBar as a slider because I can't find anything else, but I have to do so much hacky work because it doesn't allow me to set a minimum value or go in between ints. So, any time I need a slider to start at a value other than 0 or return a floating point number, I have to set a max value that doesn't describe the true max value of the control and then divide and/or add/subtract the "progress" value when I read it. Before I finish writing an entire class just to handle converting my slider values, is there a better way? I'm using Android 1.6...is there a slider control in 2.0 or any other documented future release?
A SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch the thumb and drag left or right to set the current progress level or use the arrow keys. Placing focusable widgets to the left or right of a SeekBar is discouraged. Clients of the SeekBar can attach a SeekBar.
The SeekBar class is a subclass of ProgressBar , which contains a getProgress() method. Calling PRICEbar. getProgress() will return the value you are looking for.
Before I finish writing an entire class just to handle converting my slider values, is there a better way?
Not really. For starters, you really don't want something like SeekBar
doing floating-point arithmetic along the way, as most phones lack floating-point support in hardware, so floating-point operations are slow. As to why they didn't allow you to set your own custom minimum, instead of just the maximum, I cannot say.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With