@ohos.arkui.advanced.ComposeListItem (List)
The list component is a container that presents a series of items arranged in a column with the same width. You can use it to present data of the same type in a multiple and coherent row style, for example, images or text.
NOTE
This component is supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version.
Modules to Import
import { ComposeListItem } from "@ohos.arkui.advanced.ComposeListItem"
Child Components
Not supported
Attributes
The universal attributes are supported.
ComposeListItem
ComposeListItem({contentItem?: ContentItem, operateItem?: OperateItem})
Decorator: @Component
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Decorator | Description |
---|---|---|---|---|
contentItem | ContentItem | No | @Prop | Elements on the left and in the center. |
operateItem | OperateItem | No | @Prop | Element on the right. |
ContentItem
Name | Type | Mandatory | Description |
---|---|---|---|
iconStyle | IconType | No | Icon style of the element on the left. |
icon | ResourceStr | No | Icon resource of the element on the left. |
primaryText | ResourceStr | No | Title of the element in the center. If the length limit is reached, an ellipsis (...) is displayed to represent clipped text. |
secondaryText | ResourceStr | No | Subtitle of the element in the center. If the length limit is reached, an ellipsis (...) is displayed to represent clipped text. |
description | ResourceStr | No | Description of the element in the center. If the length limit is reached, an ellipsis (...) is displayed to represent clipped text. |
IconType
Name | Value | Description |
---|---|---|
BADGE | 1 | The icon on the left is a badge, in the size of 8 x 8 dp. |
NORMAL_ICON | 2 | The icon on the left is a small icon, in the size of 16 x 16 dp. |
SYSTEM_ICON | 3 | The icon on the left is a system icon, in the size of 24 x 24 dp. |
HEAD_SCULPTURE | 4 | The icon on the left is a profile picture, in the size of 40 x 40 dp. |
APP_ICON | 5 | The icon on the left is an application icon, in the size of 64 x 64 dp. |
PREVIEW | 6 | The icon on the left is a preview image, in the size of 96 x 96 dp. |
LONGITUDINAL | 7 | The icon on the left uses an aspect ratio where width is greater than height, with the longest edge being 96 dp. |
VERTICAL | 8 | The icon on the left uses an aspect ratio where height is greater than width, with the longest edge being 96 dp. |
OperateItem
Name | Type | Mandatory | Description |
---|---|---|---|
arrow | OperateIcon | No | The element on the right is an arrow, in the size of 12 x 24 dp. |
icon | OperateIcon | No | First icon of the element on the right, in the size of 24 x 24 dp. |
subIcon | OperateIcon | No | Second icon of the element on the right, in the size of 24 x 24 dp. |
button | OperateButton | No | The element on the right is a button. |
switch | OperateCheck | No | The element on the right is a switch. |
checkbox | OperateCheck | No | The element on the right is a check box, in the size of 24 x 24 dp. |
radio | OperateCheck | No | The element on the right is a radio button, in the size of 24 x 24 dp. |
image | ResourceStr | No | The element on the right is an image, in the size of 48 x 48 dp. |
text | ResourceStr | No | The element on the right is text. |
OperateIcon
Name | Type | Mandatory | Description |
---|---|---|---|
value | ResourceStr | Yes | Resource of the icon or arrow on the right. |
action | ()=>void | No | Click event of the icon or arrow on the right. |
OperateButton
Name | Type | Mandatory | Description |
---|---|---|---|
text | ResourceStr | No | Button text on the right. |
OperateCheck
Name | Type | Mandatory | Description |
---|---|---|---|
isCheck | boolean | No | Whether the switch, check box, or radio button on the right is selected. Default value: false true: selected false: not selected |
onChange | (value: boolean)=>void | No | Callback invoked when the selected state of the switch, check box, or radio button on the right is changed. true: from not selected to selected false: from selected to not selected |
Events
The universal events are supported.
Example
import { IconType, ComposeListItem } from '@ohos.arkui.advanced.ComposeListItem';
import promptAction from '@ohos.promptAction'
@Entry
@Component
struct ComposeListItemExample {
build() {
Column() {
List() {
ListItem() {
ComposeListItem({
contentItem: ({
iconStyle: IconType.NORMAL_ICON,
icon: $r('sys.media.ohos_app_icon'),
primaryText: 'Two-row list',
secondaryText:'Secondary text'
}),
operateItem: ({
icon: {
value: $r('sys.media.ohos_app_icon'),
action: () => {
promptAction.showToast({ message: 'icon' })
} },
text:'Text on the right'
})
})
}
}
}
}
}