Propagandian
Propagandian

Reputation: 452

TextFields not updating/repainting correctly on codenameone

I have a problem with TextFields not updating correctly when they gain focus using the virtual keyboard in Codenameone apps on Android devices.

I gave the TextField a value (value '0') and added multiples underneath each other. I then pressed on a TextField, where it gains focus, and I type something in. Once the value is entered, I press 'Next' on the virtual keyboard, and the value in the next TextField (the '0') gets bolded (there's 2 '0' values on top of one another). When I then press back, to clear the '0', one of them disappear, and when I try type, the text if written over the '0' value.

This seems to happen when the next TextField is off-screen, and it seems to not update correctly. When I erase one '0', and lose focus on the TextFields, the other '0' also disappears, implying its not refreshing correctly. The same happens with text hints.

The test app I used:

CODE SAMPLE

public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Hi World");
    hi.addComponent(new Label("Hi World"));
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.addComponent(getEntry());
    hi.show();
}

public Container getEntry() {
    Container c = new Container();
    c.setLayout(new BorderLayout());
    Label lbl = new Label("Testing..");

    TextField tf = new TextField();
    tf.setConstraint(TextField.DECIMAL);
    tf.setText("0");
    c.add(BorderLayout.NORTH, lbl);
    c.add(BorderLayout.CENTER, tf);
    return c;

}

SCREENSHOTS

In the first image, you can see the text being bolded, which is actually 2 '0' values on top of one another.

the text being bolded

The second image is what it looks like after you pressed the back button on the virtual keyboard to erase the '0'.

enter image description here

The third image shows what happens if you continue to try type something in,

enter image description here

and lastly, the fourth image shows how the TextField looks like after it loses focus (pressed on another TextField).

enter image description here

FURTHER DETAILS

This was replicated on Android devices, using versions 4.2.2, and 4.4.2. This is far easier to reproduce on smaller screens; I believe this is due ot the nature of the bug where the TextField is off-screen.

Upvotes: 2

Views: 186

Answers (1)

Chen
Chen

Reputation: 3760

Try to set the layout of your Form to

setLayout(new BoxLayout(BoxLayout.Y_AXIS));
setScrollableY(true);

Upvotes: 1

Related Questions