Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

My scrollable manager is not scrolling

by Retired ‎02-16-2010 03:36 PM - edited ‎09-16-2010 02:29 PM (4,946 Views)

Summary

 

This article applies to BlackBerry® wireless devices based on Java™.

 


Problem

 

A manager created with the Manager.HORIZONTAL_SCROLL or Manager.VERTICAL_SCROLL style enables scrolling if focusable fields are located outside of the visible portion of the manager. This can cause an issue for managers that do not contain any focusable fields; however, it does not mean that such managers are not scrollable.

 

Resolution

 

To enable scrolling on a manager with non-focusable fields, use the NullField class. By adding focusable NullFields throughout the manager, you can allow the user to scroll through it.

 

Note: A NullField is not visible to the user.

 

Here is an example of a NullField:

 

 

MainScreen mainScreen = new MainScreen();

//Create a scrollable VerticalFieldManager.
VerticalFieldManager vfm = new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL);

//Add a focusable NullField to the top of the screen to allow the user to scroll to the top.
vfm.add(new NullField(NullField.FOCUSABLE));

//Add 10 fields. They will not quite fit on the screen of a BlackBerry 7200 Series of Wireless Handheld™.
//Comparing to 0 and decrementing is faster on a BlackBerry wireless device than incrementing and comparing
//to a non zero value.
for (int count = 10; count >= 0; --count)

{
vfm.add(new LabelField("Field number " + count, LabelField.NON_FOCUSABLE));
vfm.add(new SeparatorField());

}

//Add a focusable NullField to the bottom of the screen to allow the user to scroll to the bottom.
vfm.add(new NullField(NullField.FOCUSABLE));

mainScreen.add(vfm);
pushScreen(mainScreen);

 

Contributors
Users Online
Currently online: 25 members 689 guests
Please welcome our newest community members: