# WRTKit ListView Class

## Description

The ListView is a view that arranges controls in a vertical stack similar to native S60 user interfaces.

Figure 1. ListView with caption

## Inherits from

View

Parent topic: WRTKit API Reference

## Constructor

### Syntax

    [ListView] new ListView(String id, String caption)

### Description

Creates a new instance of the ListView class.

### Arguments

- id

  Unique identifier for the view. Can be retrieved using the id property defined in the UIElement class that this control inherits from. Useful for example to identify the source of an event in event callback functions or to apply a CSS rule to only this particular view. The identifier can be null, in which case no id will be set for the view.

- caption

  The caption text for the view. A null caption can be used to hide the caption area. Pass an empty string to this argument in order to show the caption area but without text. This can be used if a custom image should be shown instead of text for the view caption. The image can then be defined using CSS by providing a background for the .ListViewCaptionText CSS rule. By specifying the rule only for the id that was specified with the id argument a custom background can be given to a particular view. The value is an XHTML string.

### Return value

A new instance of the ListView class.

## getCaption()

### Syntax

    [String] ListView.getCaption(void)

### Description

Retrieves the current caption of the view. The value is an XHTML string.

### Arguments

This method does not take any arguments.

### Return value

The current caption of the view or null if the view doesn't have a caption.

## setCaption()

### Syntax

    [void] ListView.setCaption(String caption)

### Description

Sets the caption for the view. A null caption can be used to hide the caption area. The value is an XHTML string.

### Arguments

- caption

  The new caption for the view or null for no caption.

### Return value

This method does not return a value.

## getControls()

### Syntax

    [Array] ListView.getControls(void)

### Description

Retrieves the controls of this view.

### Arguments

This method does not take any arguments.

### Return value

An array with the controls of this view or an empty array if the view doesn't have any controls.

## addControl()

### Syntax

    [void] ListView.addControl(Control control)

### Description

Adds a control to the view. The control is added last, below the currently last control.

### Arguments

- control

  The control to add to the view.

### Return value

This method does not return a value.

## insertControl()

### Syntax

    [void] ListView.insertControl(Control control, Control beforeControl)

### Description

Inserts a control to the view. The control is added before the control that is specified using the beforeControl argument.

### Arguments

- control

  The control to add to the view.

- beforeControl

  The control that should be immediately after the added control after the new control is added to the view. If the argument is null or otherwise invalid (e.g. not a control in this view) then the new control is added last.

### Return value

This method does not return a value.

## removeControl()

### Syntax

    [void] ListView.removeControl(Control control)

### Description

Removes a control from the view.

### Arguments

- control

  The control to remove from the view.

### Return value

This method does not return a value.