java – Slider control in Android…is SeekBar really my best/only option?-ThrowExceptions

Exception or error:

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?

How to solve:

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.

Leave a Reply

Your email address will not be published. Required fields are marked *