2012-04-19 189 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