1
votes

Can any one please tell me how i can add slider and moving form in codename one (with sample lines of code) and also want to know are these features supported by all types of devices? Regards, Megha

2
What's a Slider & moving form? There is a Slider class in Codename One do you mean that? - Shai Almog

2 Answers

0
votes

I think you mean how to animate forms changes

Form.setTransitionInAnimator(CommonTransitions.somthing)
Form.setTransitionOutAnimator(CommonTransitions.somthing)

Next, you should handle some "finger slide" event.

0
votes

To add a slider you can use the following code

    Slider jSlider = new Slider();
    jSlider.setMaxValue(255);
    jSlider.setMinValue(0); 
    jSlider.setProgress(50); // Set  the starting value
    jSlider.setEditable(true); // To it works as a slider instead of a progress bar

Now you have created a slider which you can add to your component like you would in Swing. You can type 'jSlider.' in eclipse to find out which other methods you can use, or you can go to the API: http://codenameone.googlecode.com/svn/trunk/CodenameOne/javadoc/com/codename1/ui/Slider.html

I think min/maxValue are selfexplenatory though :)

If you want to open a new form, simply create a new class extending form or do it in code like

Form form = new Form();
form.animate(); // To make it "slide in"
form.show();

Also noteworthy, the slider doesn't work with the lumia skin per default, though you can make it work. I actually asked this question on here as well: Slider doesn't draw (CodeName One) with Windows phone skin