How to Use Spin Boxes (Part One)


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

Stay tuned!

About Mike Kirkup

Mike Kirkup is the Director for the Developer Relations program at Research In Motion (RIM), which is responsible for managing the technical relationships and programs for RIM’s developer community worldwide. Mike and his team work with RIM’s developer community to provide support and guidance as developers work to integrate their applications to the BlackBerry platform. Mike joined RIM in 2001 as a Security Software Developer in RIM’s Wireless Security Group. As part of the Wireless Securty group, Mike contributed to the development of the BlackBerry Cryptography API, S/MIME and PGP implementations. Mike holds a Masters of Management Science and a Bachelor of Mathematics from the University of Waterloo.

Join the conversation

Show comments Hide comments
+ -
  • Tuyen Nguyen

    Great post !!!
    I like it.

  • Bilal Khartabil

    I’m not sure why but the import statements component.TextSpinBoxField and container.SpinBoxFieldManager cannot be seen and gives an error. Anyone know whats wrong?? Cannot be resolved it says

blog comments powered by Disqus