09-06-2012 04:55 AM
Hii,i have created one slider Bar by referring the example :https://github.com/blackberry/Samples-for-Java/blo
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.
Bitmap.getBitmapResource("slider2_base_normal.png"
Bitmap.getBitmapResource("slider2_thumb_focused.pn
Bitmap.getBitmapResource("slider2_progress_focused
Bitmap.getBitmapResource("slider2_base_focused.png
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?
Solved! Go to Solution.
09-06-2012 05:08 AM
09-06-2012 05:26 AM
public int getPreferredWidth()
{
return Integer.MAX_VALUE;
}
what should i change in this code?
09-06-2012 05:45 AM
Set the width you want it to be - in pixels.
09-06-2012 06:20 AM
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.
Bitmap.getBitmapResource("slider2_base_normal.png"
Bitmap.getBitmapResource("slider2_thumb_focused.pn
Bitmap.getBitmapResource("slider2_progress_focused
Bitmap.getBitmapResource("slider2_base_focused.png
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.getHeigh
setExtent(width, actualHeight);
}
}
}
09-06-2012 06:25 AM
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.getHeigh
setExtent(width, actualHeight);
}
}
09-06-2012 06:47 AM
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-Develo
and this:
and this:
http://supportforums.blackberry.com/t5/Java-Develo
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.