String picker is not working and breaking the form

Viewed 20

I have a form set with BoxLayout.Y_AXIS.

I tried adding a string picker, but when I click on it, the form gets broken. You can see the result on the screenshots. Here is the code of the picker and how it's being added to the form:

String[] characters = { "One Person $100", "A group $360"};
        Picker picker = new Picker();
        picker.setStrings(characters);
        picker.setSelectedStringIndex(0);

TableLayout t1 = new TableLayout(1, 2);
        Container cntPicker = new Container(t1);
        cntPicker.add(t1.createConstraint().widthPercentage(40).verticalAlign(CENTER), lblSend)
                .add(t1.createConstraint().widthPercentage(-2).verticalAlign(CENTER), picker);

Container ContentHolder = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        ContentHolder.setUIID("SectionContainer");
        ContentHolder.add(cntPicker);
add(ContentHolder);

I'll really appreciate your ideas on this matter!

1

2

1 Answers

I just tried this and it worked for me, I'm assuming there's a problem in the styling such as you changing the style of Container, Label or some other global UIID in a way that impacts the picker.

This was my test case, you can use it to spot the differences:

public class MyApp extends Lifecycle {
    @Override
    public void runApp() {
        Form hi = new Form("Hi World", BoxLayout.y());

        String[] characters = { "One Person $100", "A group $360"};
        Picker picker = new Picker();
        picker.setStrings(characters);
        picker.setSelectedStringIndex(0);

        TableLayout t1 = new TableLayout(1, 2);
        Container cntPicker = new Container(t1);
        cntPicker.add(t1.createConstraint().widthPercentage(40).verticalAlign(CENTER), new Label("Pick a person"))
                .add(t1.createConstraint().widthPercentage(-2).verticalAlign(CENTER), picker);

        hi.add(cntPicker);

        hi.show();
    }
}

Screenshot

Related