Tools

Namespaces

Variants

Views

Actions

Search

Contents

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

How to enable Action Button 1 when using Lists on Series 40 Full Touch

This code example shows how you can implement lists with a Command on Action Button 1. This is useful for creating lists which can be accepted and closed using a single click on Series 40 Full Touch devices.

Contents

Overview

On Series 40 Full Touch devices (Java Runtime 2.0.0), LCDUI Lists do not support support Command Actions on Action Button 1. As shown in the screenshots below, lists of type Multiple are displayed with a dimmed Action Button 1 (shown circled in yellow) that cannot be removed or assigned to a Command, while lists of type Exclusive and Implicit are displayed with no Action Button 1 at all.

List instance of Multiple type: Action Button 1 is dimmed

List instance of Exclusive type: Action Button 1 is disabled

List instance of Implicit type: Action Button 1 is disabled

This means that it is not possible to implement an LCDUI list (other than type implicit) that is closed and acknowledged in a single click (actions assigned to the list are available under Action Button 2 (the menu), which means that they require two taps to invoke).

The following sections explain how you can implement the three list types with a command on Action Button 1, using either Form or LWUIT.

Multiple-type lists

The table below provides screenshots (and source code) for "Multiple" lists, implemented using LCDUI, a Form and a ChoiceList, and LWUIT. Note that the LCDUI and LWUIT implementations have a functional Command on Action Button 1.

Manually adding the Mark All and Unmark All functionality

Mark and unmark options are added automatically in List instances but the OK Command is added under Action Button 2

Mark and unmark options are added manually in Form instances. The OK Command remains in Action Button 1

Mark and unmark options are added manually in LWUIT for Series 40. The OK Command remains in Action Button 1

Note: When porting from an LCDUI List to a LCDUI Form or LWUIT Form, we need to manually add the mark and unmark Commands, in order to maintain the same functionality, because ChoiceGroups and CheckBoxes do not provide these options by default.

ChoiceGroups receive an array of boolean values as flags in order to set each choice item to the selected or unselected state. By passing a flag boolean array where all values are set to true or false to the ChoiceGroup we can achieve a similar mark all and unmark all functionality respectively:

Exclusive lists

The table below provides screenshots (and source code) for exclusive lists, implemented using LCDUI, a Form and a ChoiceList, and LWUIT. Note that the LCDUI and LWUIT implementations have a functional Command on Action Button 1.

Implicit lists

The table below provides screenshots (and source code) for implicit lists, implemented using LCDUI, a Form and a ChoiceList, and LWUIT. Note that the LCDUI and LWUIT implementations have a functional Command on Action Button 1.

LWUIT Form for Series 40 with List Component: Action Button is enabled

LCDUI Implicit Lists, suffer from the same problem where, all the high level Commands, with the exception of the EXIT Command, are added under the Options Menu.

Note: For implicit lists this isn't such a big problem, because choosing a list item is also implicit selection. However while an "OK" or "tick" is not required, other use cases may require a command in Action Button 1.

This can be fixed with LCDUI CustomItems, but this solution is not as easy, because CustomItems tend to have low level Canvas-like paint operations. On top of that we need to adjust the height of the item to match our needs. Each item in this case is represented as a separate class, that we call TouchItem. When we instantiate a TouchItem, we define its height. We also set the direct touch trait to true:

//If the device is Series 40 Touch and Typeif(supportsS40Touch()){//enables the single touch trait LCDUIUtil.setObjectTrait(item, "nokia.ui.s40.item.direct_touch", newBoolean(true));}//If the device is older Series 40 with keyboardelse{//adds a Select Command as Middle Softkey item.addCommand(selectCmd); item.setItemCommandListener(this);} mainForm.append(item);}

Then inside the TouchItem class, we paint the CustomItem's Canvas starting from the topmost and leftmost pixel of the item.

Note: If the item contains text that exceeds the width of the CustomItem, we need to manually adjust the height of the CustomItem or simply cut the remaining characters.