LWUIT 中 TextArea 的滚动问题
我在 LWUIT 中有一个 TextArea
,但在操作时遇到问题。我有以下两个问题:
即使我调用
setIsScrollVisible(true)
,我似乎也没有 滚动条,当输出低于可见值时无法滚动 容器的区域。如何告诉
TextArea
自动滚动到底部 以编程方式?
我的初始化 TextArea 的代码如下所示:
myTextArea = new TextArea(20, Display.getInstance().getDisplayWidth());
myTextArea.setEditable(false);
myTextArea.setEnabled(true);
myTextArea.setIsScrollVisible(true);
myTextArea.setGrowByContent(false);
System.out.println(myTextArea.isScrollableY());
isScrollableY()
返回 true。有什么想法吗?我有什么遗漏的吗? API 中似乎没有任何可见内容可以让我显式启用或禁用滚动。预先感谢您对此提供的任何帮助。
I have a TextArea
in LWUIT that I am having an issue manipulating. I have the following two issues:
Even though I call
setIsScrollVisible(true)
, I do not seem to have a
scrollbar and cannot scroll when the output goes below the visible
area of the container.How do I tell the
TextArea
to automatically scroll to the bottom
programmatically?
My code for initializing the TextArea looks like this:
myTextArea = new TextArea(20, Display.getInstance().getDisplayWidth());
myTextArea.setEditable(false);
myTextArea.setEnabled(true);
myTextArea.setIsScrollVisible(true);
myTextArea.setGrowByContent(false);
System.out.println(myTextArea.isScrollableY());
isScrollableY()
returns true. Any ideas? Is there something I am missing? There doesn't seem to be anything visible in the API that lets me explicitly enable or disable scrolling. Thanks in advance for any assistance on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文本区域的宽度以列为单位,而不是代码中的像素。
将滚动设置为可见不会导致它出现,因为 LWUIT 滚动条始终“根据需要”,这意味着滚动条仅在必要时才会出现,将此值设置为 false 只会隐藏滚动条,无论是否必要。
要让文本区域占据整个宽度,只需将其放置在框布局 Y 容器/表单中,布局管理器将在 X 轴上拉伸它。
您可以使用
scrollRectToVisible()
将文本区域滚动到底部,或者您可以派生文本区域并使用setScrollY(int)
和适当的值(请参阅源代码文本区域,了解如何使用它来滚动文本区域。The width of the text area is in columns NOT pixels as you have in your code.
Setting the scroll to visible won't cause it to appear since LWUIT scrollbars are always "as needed" which means a scrollbar will only appear when necessary, setting this value to false would just hide the scrollbar regardless of necessity.
To have the text area grab the entire width just place it within a box layout Y container/form and the layout manager will stretch it on the X axis.
You can use
scrollRectToVisible()
to scroll the text area to the bottom or alternatively you can derive text area and usesetScrollY(int)
with the appropriate value (see the source code of text area for how this is used to scroll the text area.尝试一个简单的
textArea.setFocusable(false)
。这对我有用。Try a simple
textArea.setFocusable(false)
. This worked for me.