如何在lwuit(J2ME)中显示多行textAreas?

Ami*_*mit 2 java lwuit java-me

我创建了一个TextArea声明....

quest1Label = new TextArea();
Run Code Online (Sandbox Code Playgroud)

我正在使用TextArea显示Labels....所以我使用以下功能来设置其属性....

private void setTextAreaProperty(TextArea textArea) {
    String textStr = textArea.getText();
    if (textArea.getStyle().getFont().stringWidth(textStr) > (width - 25)) {
        textArea.setSingleLineTextArea(false);
    } else {
        textArea.setSingleLineTextArea(true);
        textArea.setPreferredW(width);
    }
    textArea.setBorderPainted(false);
    textArea.setFocusable(false);
    textArea.setStyle(getPreviewStyle());
}
Run Code Online (Sandbox Code Playgroud)

其中width = Display.getInstance().getDisplayWidth(); 我的问题是最多两行标签正常工作,但....如果文字更大,它不会到第三行.任何有关这方面的帮助将不胜感激.

提前致谢,....

Sha*_*mog 7

您需要使用这样的TextArea构造函数,这样new TextArea(1, 20)可以使布局更有效地"增长".

原因主要是历史性的,LWUIT有一个3列默认值TexAarea,允许TexAarea收缩良好,但在成长时很糟糕.增长/缩小的复杂性源于布局可以深度嵌套和可滚动的事实,因此可用空间与期望空间计算变得递归并且在某些难以检测的点处无法解决(无限递归).