Category bar

This is one of the Series 40 platform features integrated to LWUIT for Series 40. Category bar was introduced in Series 40 full touch UI. It is the recommended way of showing parallel views.

Category bar is easy to use in any ordinary Series 40 full touch MIDlet. The "tabs" use icons that will automatically use the active device theme colour. Labels are not supported.

The following excerpt is taken from the LWUIT CategoryBarDemo project that is available in the <Nokia SDK 2.0 for Java installation directory>\plugins\lwuit\examples directory. The views are regular LWUIT forms which are added to IconCommands. The IconCommand extends the regular Command. The CategoryBar is initialised with the commands.

// Initialize views.
views = new Vector();
views.addElement(new AddContentView());
showView(0);
views.addElement(new ImageView());
views.addElement(new AboutView(
    getAppProperty("MIDlet-Name"),
    getAppProperty("MIDlet-Vendor"),
    getAppProperty("MIDlet-Version")));

// Create icon commands for a category bar.
IconCommand[] iconCommands = new IconCommand[views.size()];
for (int i = 0; i < iconCommands.length; i++) {
    Image icon = (Image) ImageUtil.loadImage(
        ((View) views.elementAt(i)).getIconPath()).getImage();
    iconCommands[i] = new IconCommand(
        ((View) views.elementAt(i)).getLabel(),
        icon,
        null,
        Command.SCREEN, 1);
}

// Create a category bar using the icon commands.
categoryBar = new CategoryBar(iconCommands, true);

// Set an element listener for the category bar.
categoryBar.setElementListener(DemoMidlet.this);

// Show the category bar.
categoryBar.setVisibility(true);

An example of a Category bar is displayed in Figure 1.

Figure: Form with Category bar