tags:

views:

750

answers:

4

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

+1  A: 

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 as MainScreen(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 http://stackoverflow.com/questions/1660230/blackberry-verticalfieldmanager-with-fixed-size-scroll-issue if you are concerned about that issue.

Jessica
A: 

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 and VERTICAL_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 the paint 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 using g.drawRect() or something similar.

Anidamo
A: 

abcdefghijklmnop

ram
A: 

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

Arkady.