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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


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

BlackBerry java Slider Bar

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

 

by this,i am successfully displayed slider on my Screen,but my problem is beside the slider  Bar,i want to display one play/pause button,for that i have used the below code:


public class UIExampleSliderScreen extends UIExampleScreen {
private ButtonField _startPlayingButton;
private ButtonField stop;

private ButtonField facebookButton;

public UIExampleSliderScreen() {
super(0);
_startPlayingButton = new ButtonField("Play");
stop = new ButtonField("Stop");

facebookButton = new ButtonField("Facebook");
facebookButton.setMargin(5, 5, 5, 5);
HorizontalFieldManager manager = new HorizontalFieldManager();

setTitle("Slider Screen");
final SliderField slider;
slider = new SliderField(
Bitmap.getBitmapResource("slider2_thumb_normal.png"),
Bitmap.getBitmapResource("slider2_progress_normal.png"),
Bitmap.getBitmapResource("slider2_base_normal.png"),
Bitmap.getBitmapResource("slider2_thumb_focused.png"),
Bitmap.getBitmapResource("slider2_progress_focused.png"),
Bitmap.getBitmapResource("slider2_base_focused.png"), 20,
0, 16, 16, FOCUSABLE);
slider.setPadding(20, 20, 20, 20);

slider.setBackground(BackgroundFactory
.createSolidBackground(0xD3D3D3));

manager.add(slider);

manager.add(facebookButton);

manager.add(_startPlayingButton);
manager.add(stop);
add(manager);

}


}
}

 

1)i am able to display only the Slide Bar,my custom Buttons are not displayed?

2)The Slide Bar is Displayed on Screen fully,how can i reduce the lenth of my slide Bar?

 

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: BlackBerry java Slider Bar

the slider field seems to be designed to occupy the whole width:
public int getPreferredWidth()
{
return Integer.MAX_VALUE;
}

you would have to change that, or overwrite the layout of the manager.
see
http://supportforums.blackberry.com/t5/Java-Development/How-to-Extend-Manager/ta-p/446749
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
Posts: 63
Registered: ‎08-30-2012
My Device: 9900
My Carrier: Various

Re: BlackBerry java Slider Bar

public int getPreferredWidth() 
{
return Integer.MAX_VALUE;
}

 

what should i change in this code?

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: BlackBerry java Slider Bar

Set the width you want it to be - in pixels. 

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

Re: BlackBerry java Slider Bar

hi,can you check once my code is it correct: i am facing error

public class SeekBar extends UiApplication {
private static SeekBar bar;
private UIExampleSliderScreen screen;
SliderField slider;

public static void main(String args[]) {
bar = new SeekBar();
bar.enterEventDispatcher();
}

public SeekBar() {
screen = new UIExampleSliderScreen();
pushScreen(screen);
}

public class UIExampleSliderScreen extends UIExampleScreen {
private ButtonField _startPlayingButton;
//private ButtonField stop;

private ButtonField facebookButton;

public UIExampleSliderScreen() {
super(0);
_startPlayingButton = new ButtonField("Play");

facebookButton = new ButtonField("Facebook");
facebookButton.setMargin(5, 5, 5, 5);
HorizontalFieldManager manager = new HorizontalFieldManager();

setTitle("Slider Screen");

slider = new SliderField(
Bitmap.getBitmapResource("slider2_thumb_normal.png"),
Bitmap.getBitmapResource("slider2_progress_normal.png"),
Bitmap.getBitmapResource("slider2_base_normal.png"),
Bitmap.getBitmapResource("slider2_thumb_focused.png"),
Bitmap.getBitmapResource("slider2_progress_focused.png"),
Bitmap.getBitmapResource("slider2_base_focused.png"), 20,
0, 16, 16, FOCUSABLE);
slider.setPadding(20, 20, 20, 20);

slider.setBackground(BackgroundFactory
.createSolidBackground(0xD3D3D3));


manager.add(_startPlayingButton);

manager.add(slider);

etStatus(manager);

}
protected void sublayout(int width, int height) {

layoutChild(_startPlayingButton, width, height);
layoutChild(slider, width-_startPlayingButton.getWidth(), height);

setPositionChild(_startPlayingButton, width-slider.getWidth(),0);
setPositionChild(slider, 10, 10);
int actualHeight=Math.max(_startPlayingButton.getHeight(), slider.getHeight());
setExtent(width, actualHeight);
}


}
}

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

Re: BlackBerry java Slider Bar

if i do like this,i am not able to display my slider Bar:,but i am able to display my title

 

public class UIExampleSliderScreen extends UIExampleScreen {

public  UIExampleSliderScreen {

setTiltle("Title");

SliderButton button=new SliderButton(slider,_startPlayingButton);

 

}

 

public class SliderButton extends Manager {
private ButtonField _startPlayingButton;
private ButtonField stop;
SliderField slider1;
protected SliderButton(SliderField slider, ButtonField _startPlayingButton){
super(0);
this._startPlayingButton=_startPlayingButton;
slider1=slider;
//add(_startPlayingButton);
System.out.println("SliderButton");

add(slider1);
System.out.println("SliderButton1");
HorizontalFieldManager manager = new HorizontalFieldManager();
manager.add(_startPlayingButton);
manager.add(slider);
add(manager);
}

protected void sublayout(int width, int height) {

layoutChild(_startPlayingButton, width, height);
layoutChild(slider1, width-_startPlayingButton.getWidth(), height);

setPositionChild(_startPlayingButton, width-slider1.getWidth(),0);
setPositionChild(slider1, 10, 10);
int actualHeight=Math.max(_startPlayingButton.getHeight(), slider1.getHeight());
setExtent(width, actualHeight);
}

}

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: BlackBerry java Slider Bar

Please start a new Thread for this new Problem.

 

I have not looked seriously at your code, but it looks a little odd in places.  Can I suggest you review this:

http://supportforums.blackberry.com/t5/Java-Development/How-to-Extend-Manager/ta-p/446749

and this:

http://supportforums.blackberry.com/t5/Java-Development/Create-a-custom-layout-manager-for-a-screen/...

and this:

http://supportforums.blackberry.com/t5/Java-Development/Create-custom-fields/ta-p/444962

 

Then I think you will understand the theory of what you are trying to do a bit better.  Having reviewed all of this, look at your code again, Play around with it, then come back to us with your question on a new Thread.