Home Ask Login Register

Developers Planet

Your answer is one click away!

JDKSoftDev February 2016

Best method of checking a value in ranges in android?

I'm designing a roulette app. I need a way to take my ending rotation, "wheelRotateTo" and find out, in a list of degrees, which are currently in a stack of 36 "segments" on the wheel.

So if the end degree is 355, it should identify the last stack object, because it's < 360, but greater than the degree of the segment below it..

Likewise, if wheelRotateTo was 339, it should give me the second stack segment down, because it fits there.

This is just driving me crazy. Can someone explain a reasonable way to identify which segment or "Wheel number" it stops on?

Thank you.


Code-Apprentice February 2016

I can think of several solutions:

  1. Divide the number of degrees by the number of degrees per section. This will give you the index for the section in your list.

  2. Don't worry about degrees at all. Just randomly generate an index to your list.

Post Status

Asked in February 2016
Viewed 2,260 times
Voted 5
Answered 1 times


Leave an answer

Quote of the day: live life