SliderBar

20 views
Skip to first unread message

Steve Marcus

unread,
Aug 18, 2013, 1:08:07 PM8/18/13
to alternate-java-bridg...@googlegroups.com
I can set sliderBar Max position using

aBSliderBar1.PositionMax(30);

How can I set sliderBar Min Position? say for example if I want the lowest value to be 10.

Also does the Event POSITION_CHANGED accept any args for thumb position? say like:

if (component.equals(sliderBarStartingCredits) && eventName.equals(Events.POSITION_CHANGED)) {
SliderBar1Changed(Convert.Int(args[0]));
return true;
    }

Thanks,


S

Imp Inc

unread,
Aug 18, 2013, 7:37:00 PM8/18/13
to alternate-java-bridg...@googlegroups.com
No, right now there is no way to set the min.

This can change of course. The difference would be that it would no longer be 1 based. Right now, the lowest number is 1. This would change to 0.

One of the things AI did was to make things 1 based, in an effort to make things make more sense. If I want the first entry, I use 1. However, this becomes a big pain when working in Java, as everything in Java is 0 based.

So now the default settings would be:
100 total positions
0 first available position (slider all the way to the left)
99 last available position (slider all the way to the right)

As for the event, it can be modified to add the position, however, you can also call the sliderBar1.Position() method to get the current position of the bar. I'll add the position to the event anyways.

There's also a boolean that is returned in the event, telling you if it was moved by the user or not.

The first argument is the boolean, the second will be the position.

I'll get the jar updated and on the deploy site soon.

Ryan

Imp Inc

unread,
Aug 18, 2013, 9:06:32 PM8/18/13
to alternate-java-bridg...@googlegroups.com
Scratch that. I just put it back to how it was. There is no way to set the minimum (in the android Seekbar component).

Steve Marcus

unread,
Aug 19, 2013, 8:18:00 AM8/19/13
to alternate-java-bridg...@googlegroups.com
Hmm ok that's a problem. I guess what I could do is something like

if (thumbPosition < 10) {thumbPosition = 10}; 

But then it would not show correctly on the display,it would show the slider at position 10 instead of all the way to the left.

Or perhaps I could use a dummy variable, if if (thumbPosition < 10) {dummyVariable = 10}; then use that variable to for the calculations instead. But it would still appear incorrect when sliding I imagine.


Imp Inc

unread,
Aug 19, 2013, 11:44:54 AM8/19/13
to alternate-java-bridg...@googlegroups.com
This is how you should do it:

The sliderbar starts at 1, but we want it to start at 10.

So, 10 - 1 = 9.

Take the highest number we want to allow, then subtract our difference:

30 - 9 = 21.

So, whenever you read the position, always add 9 to it. Set the PositionMax to 21. So, when it's at the left (1), it will be 10 after adding 9. All the way to the right (21), it would be 30 after adding 9.

I hope this makes a little more sense for you.

Ryan

Steve Marcus

unread,
Aug 20, 2013, 7:13:25 AM8/20/13
to alternate-java-bridg...@googlegroups.com
Yep got it. Ken pointed me on the right track. It's so obvious when you think about it :P My brain isn't working. Thanks,
Reply all
Reply to author
Forward
0 new messages