TextFields无法在codenameone上正确更新/重画 [英] TextFields not updating/repainting correctly on codenameone

查看:45
本文介绍了TextFields无法在codenameone上正确更新/重画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个问题,当 TextFields 在Android设备上的Codenameone应用程序中使用虚拟键盘获得焦点时,它们无法正确更新。

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

我给了 TextField 一个值(值'0'),并在其下添加了倍数。然后,我按下 TextField ,在那里获得焦点,然后键入一些内容。输入值后,我在虚拟键盘上按 Next,然后按值在下一个 TextField 中( 0)被加粗(彼此之间有2个 0值)。然后,当我再按一次以清除'0'时,其中的一个消失了,当我尝试键入时,如果该文本覆盖了'0'值。

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.

当下一个 TextField 不在屏幕上时,似乎似乎发生了这种情况,并且似乎无法正确更新。当我删除一个 0并失去对TextField的关注时,另一个 0也消失了,这表明其刷新不正确。
文本提示也是如此。

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:

代码示例

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;

}

屏幕截图

在第一张图片中,您可以看到文本为粗体,实际上是2个'0'值。

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

第二张图片是您按下虚拟键盘上的后退按钮以擦除后的样子 0。

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

第三张图片显示了如果您继续尝试输入内容会发生什么情况,

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

最后是第四个图像e显示了失去焦点(按在另一个TextField上)后的TextField的样子。

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

更多详细信息

这是在Android设备上使用4.2.2和4.4版本复制的。 2。
这在较小的屏幕上复制要容易得多;我认为这是由于 TextField 在屏幕外的错误的本质所致。

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.

推荐答案

尝试将表单的布局设置为

Try to set the layout of your Form to

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

这篇关于TextFields无法在codenameone上正确更新/重画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆