2012-04-19 181 views

回答

3

使用getVirtualHeight()getVerticalScroll()从类net.rim.device.api.ui.ManagergetVisibleHeight()net.rim.device.api.ui.ScrollView 它可以实现对经理定制滚动条。

请查阅此黑莓知识文库,Implementing a standard style scrollbar on a Blackberry device

我已经使用那个类,VerticalScrollManager,它运作良好。以下是示例代码片段和生成的输出。

代码:

int maxWidth = 200; 
int maxHeight = 100; 

VerticalScrollManager vsm = new VerticalScrollManager(maxWidth, maxHeight); 

vsm.add(new ButtonField("ButtonField 1")); 
vsm.add(new ButtonField("ButtonField 2")); 
vsm.add(new ButtonField("ButtonField 3")); 
vsm.add(new ButtonField("ButtonField 4")); 
vsm.add(new ButtonField("ButtonField 5")); 

输出:

Output of the above code

另一个有用的链接,Scrollbar Component in Blackberry

0

Javadoc中,似乎只应使用:

VERTICAL_SCROLL 
HORIZONTAL_SCROLL 

使用位运算与并不意味着在这种情况下使用可能会导致不可预测的结果值。

0

您可以覆盖VerticalFieldManager中的paint方法并从头开始绘制该滚动条,除此之外没有其他默认滚动条。

+0

但是,如何跟踪当前用户位置 – 2012-04-19 09:06:31

+0

'getVerticalScroll' – 2012-04-19 09:40:21