문제

Possible Duplicate:
Android: Set interval in SeekBar

I have a seekbar with max value as 100 So the total span of values it can take is 0-100.

but my requirement is that the progress shown on seekbar should only be in fixed steps. i.e. I only want my seekbar to take these values 1, 10 , 20, 30, 40, ....90, 100 and not any value between these steps.

how can I limit my seekbar to work in this manner?

Please help

도움이 되었습니까?

해결책

store the possible values in an array and use the current seek-bar value as the array-index.

Pseudo-code

int[] values = {1, 10 , 20, 30, 40, ....90, 100};
int current = values[ seekbar.getValue() ];

So for if seekbar.getValue() == 1 your current == 10.

다른 팁

You can make your seekbar's max as 10 and while displaying the selected value, get the current progress and multiply with 10.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top