سؤال

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