Spin boxes are one of the many new features included in the BlackBerry® Java® Application Development v5.0 Beta 3 release and provide a user friendly interface for selecting an item from a sequential list. Examples of sequential lists include numbers, dates, and names. The “spin” part of the name comes from the fact that the user spins the component to find the item. If the user spins to the end of the list, the displayed choices can wrap around so the user arrives back at the beginning of the list.
Here’s what a spin box looks like:
As seen in the screenshots above, developers can use one or more spin boxes, which are managed by a spin box manager. The manager is responsible for enforcing a common look across the controlled spin boxes e.g. height, visible rows, and padding.
Spin boxes do not necessarily have to contain only text. While RIM currently provides a text version of a spin box, developers are free to implement their own spin boxes. For example, developers can create a custom spin box that renders bitmaps. Creating custom spin boxes will be covered in a future post.
Using spin boxes in your application
As mentioned previously, the BlackBerry Java Application Development v5.0 Beta 3 release provides a text version of the spin boxes. The key components when using spin boxes include:
- One or more sets of choices
- One or more spin boxes
- A spin box manager
Here is a code snippet that will produce a spin box similar to the screenshots above.
Interested in learning more? In future posts, we will discuss:
- Advanced use of spin boxes
- How to create custom spin boxes
- The new date and time picker which uses the spin boxes