2

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

user291977
  • 237
  • 1
  • 5
  • 11
  • duplicate of http://stackoverflow.com/questions/2006076/blackberry-auto-scroll-vertical-field-manager – Maksym Gontar Mar 22 '10 at 13:15
  • that looks like a different question to me, the other question was asking about making scrolling happen automatically, this question was about showing the scrollbar. – Jessica Brown Mar 24 '10 at 23:01

3 Answers3

2

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 Blackberry VerticalFieldManager with fixed size : Scroll issue if you are concerned about that issue.

Community
  • 1
  • 1
Jessica Brown
  • 8,222
  • 7
  • 46
  • 82
0

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.

Victor
  • 1,137
  • 1
  • 10
  • 15
0

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