1

我有一个 lwiit 表格。表单的布局已设置为 BorderLayout。然后,我在表单中添加了一个容器。

IE。form.addComponent(BorderLayout.Center, some_CONtainer);

这个容器由几个项目组成,如..容器、文本区域和按钮。结果,表单远远超出了移动屏幕。

如何在表单中显示垂直滚动条,以便用户知道表单超出了屏幕范围?

现在,没有可见的滚动条。我该怎么做呢?

这是我尝试过的:

Form myForm = new Form("xyz");
myForm.setScrollable(false);

Container container = new Container();
TextArea message = new TextArea("A very long message here which goes beyond the screen length");

container.setLaynout(new BoxLayout(BoxLayout.Y_axis));
container.add(message);
container.add(new RadioButton("a1"));
container.add(new RadioButton("a2"));
container.add(new RadioButton("a3"));
container.add(new RadioButton("a4"));
container.add(new RadioButton("a5"));
container.add(new RadioButton("a6"));
container.add(new RadioButton("a7"));
container.add(new Button("press me"));
myform.addComponenet(container);
container.setScrollable(true);

现在,我希望滚动条在容器内可见。但它不起作用。我错过了什么吗?

4

1 回答 1

0

边框布局不太擅长滚动。默认情况下,表单在 LWUIT 中的 Y 轴上是可滚动的,您可以setScrollableY(true/false);适当地启用/禁用它。

编辑,因为你完全改变了问题,我什至不明白你在做什么。这段代码将完成您似乎正在尝试完成的事情,而无需所有的箍:

Form myForm = new Form("xyz");

TextArea message = new TextArea("A very long message here which goes beyond the screen length");

myForm.setLaynout(new BoxLayout(BoxLayout.Y_axis));
myForm.add(new RadioButton("a1"));
myForm.add(new RadioButton("a2"));
于 2012-03-19T14:22:15.647 回答