Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
pavankumarragi
Posts: 63
Registered: ‎08-30-2012
My Device: 9900
My Carrier: Various

Controlling Volume Through SliderBar

hi

   i have created one slider Bar by Referring the URL:https://github.com/blackberry/Samples-for-Java/blob/master/Advanced%20UI/src/com/samples/toolkit/ui/...

but i am not getting what code ,i should write to control my voulme,by dragging the slider?can any one help?

Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Controlling Volume Through SliderBar

I use a similar Field and there are just two parts to the requirement:

 

a) Create a FieldChangeListener and then associate this with the slider using code like:

 

slider.setChangeListener(< your FieldChangeListener >);

 

b) In the FieldChanged method, get the new value:

 

For example:

 

        public void fieldChanged(Field field, int context) {

                if ( field == slider ) {
                        value = slider.getValue();

       ....

 

 

Pretty much the same process is used to be notified of changes in any Field.

Please use plain text.
Regular Contributor
pavankumarragi
Posts: 63
Registered: ‎08-30-2012
My Device: 9900
My Carrier: Various

Re: Controlling Volume Through SliderBar

[ Edited ]

can you  please provide me the code to increase or decrease the volume if we drag the slider?

if(field==slider){
slider.getValue();
//what code should i place here
}

Please use plain text.
Developer
Dionysus
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900
My Carrier: MTN

Re: Controlling Volume Through SliderBar

[ Edited ]
 VolumeControl volume = (VolumeControl) player.getControl("VolumeControl");
    volume.setLevel(slider.getValue());
Please use plain text.