在黑莓应用程序中向屏幕添加垂直滚动条
嗨,我是黑莓开发的新手。
我试图在屏幕上添加垂直滚动条,但无法做到这一点。因为我不认识路。 VerticalScrollManger 滚动 = new VerticalScrollManager(Manager.VERTICAL_SCROLL);
请给我解决方案。 谢谢
hi I am new to blackberry development..
I am trying to add a vertical scroll bar on the screen, but not able to do that. because I do not know the way.
VerticalScrollManger scroll = new VerticalScrollManager(Manager.VERTICAL_SCROLL);
please give me the solution.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
扩展 net.rim.device.api.ui.Manager 的东西(如 VerticalFieldManager)可以在构造函数中设置样式位,指定您想要的滚动类型以及是否应显示滚动条(箭头) 。将您的字段放入已启用滚动的管理器中,并为屏幕设置管理器您需要设置包含对于屏幕来说太大的组件/字段的管理器,以启用滚动并绘制滚动条以查看滚动箭头。
您要设置的样式位是:
Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR
如果您的 UI 构建在黑莓类 MainScreen 或 FullScreen 之上,则可以使用采用 long 类型参数的构造函数来设置样式位:
MainScreen(long style)
可以被称为MainScreen(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
来设置屏幕的样式位以包括滚动和垂直滚动指示器箭头。偶尔会出现一个问题,即固定大小的 FieldManager 有时不会显示滚动箭头(但它们仍会滚动)。如果您担心以下问题,请参阅具有固定大小的 Blackberry VerticalFieldManager:滚动问题那个问题。
Things that extends net.rim.device.api.ui.Manager (like a VerticalFieldManager) can have style bits set in the constructor that specify which type(s) of scrolling you want and whether or not the scrollbars (arrows) should be displayed. Put your Field into a manager that has scrolling enabled and set the manager for the screen You need to set the manager containing the component/field that is too large for the screen to have scrolling enabled AND scrollbars drawn to see scroll arrows.
The style bits you want to set are:
Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR
If your UI is built on top of the blackberry classes MainScreen or FullScreen, you can use the constructor taking an argument of type long to set the style bits:
MainScreen(long style)
could be called asMainScreen(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
to set the style bits for the screen to include scrolling and vertical scroll indicator arrows.There is an occasional issue that FieldManagers that are fixed size will sometimes not show scroll arrows (but they'll still scroll). See Blackberry VerticalFieldManager with fixed size : Scroll issue if you are concerned about that issue.
如果滚动条指的是蓝色小箭头,那么您可以使用上面描述的 Jessica 方法(设置样式位
VERTICAL_SCROLL
和VERTICAL_SCROLLBAR
)来显示它们。但是,如果通过滚动条您指的是指示滚动位置的实际条(如浏览器应用程序中所示),那么您需要自己在管理器上绘制这些条,因为 BlackBerry API 不为您提供任何显示方式自动地。要执行类似的操作,您需要子类化
VerticalFieldManager
并重写paint
方法。使用屏幕高度 (Display.getHeight()
)、管理器高度 (getVirtualHeight()
) 和滚动位置 (getVerticalScroll()
) 的组合code>) 计算条形的 Y 位置和高度,然后使用g.drawRect()
或类似的方法将其绘制在屏幕上。If by scrollbars you mean the small blue arrows, then you can get these to display using the method Jessica described above (set style bits
VERTICAL_SCROLL
andVERTICAL_SCROLLBAR
). However, if by scrollbars you are referring to actual bars that indicate the scrolled position (as seen in the Browser app) then you would need to draw these on the manager yourself, as the BlackBerry API doesn't provide you with any way to display them automatically.To do something like that you'd need to subclass
VerticalFieldManager
and override thepaint
method. Use a combination of the screen height (Display.getHeight()
), the manager height (getVirtualHeight()
) and the scroll position (getVerticalScroll()
) to calculate the Y position and height of the bar, and then draw it on the screen usingg.drawRect()
or something similar.如果您想要一个更漂亮的滚动条,请查看我在黑莓知识库中的文章:
http://supportforums.blackberry.com/t5/Java-Development/Implementing-a-standard-style-scrollbar-on-a-Blackberry-device/ta-p/504416
If you want a fancier-looking scrollbar, take a look at my article in BlackBerry knowledge base:
http://supportforums.blackberry.com/t5/Java-Development/Implementing-a-standard-style-scrollbar-on-a-Blackberry-device/ta-p/504416