Skip to main content
Version: v3

CYCLE_IMAGE_TEXT_LIST

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

cycle_image_text_list_sample

Create a list that can be scrolled in a loop, and each list item can be placed with an image and text.

Create UI widget

import { createWidget, widget } from '@zos/ui'

const cycleImageTextList = createWidget(widget.CYCLE_IMAGE_TEXT_LIST, Param)

Type

Param: object

PropertiesDescriptionRequiredType
item_image_xThe x-coordinate of Image.(Relative coordinate)YESnumber
item_image_yThe y-coordinate of Image.(Relative coordinate)YESnumber
item_text_xThe x-coordinate of text.(Relative coordinate)YESnumber
item_text_yThe y-coordinate of text.(Relative coordinate)YESnumber
item_text_sizeFont Size.YESnumber
item_text_colorFont color.YESnumber
item_bg_colorBackground color.YESnumber
item_heightThe height of item.YESnumber
xThe x-coordinate of widgets.YESnumber
yThe y-coordinate of widgets.YESnumber
wThe width of widgets.YESnumber
hThe height of widgets.YESnumber
data_arrayData arrays.YESArray<Data>
data_sizeThe length of the array.YESnumber
item_text_align_hText horizontal orientation.Unfilled default horizontal centering.NOnumber
item_text_align_vVertical orientation of text.Unfilled defaults to vertical centering.NOnumber
item_text_heightActual display area of text.Default to item_height if not filled.NOnumber
item_text_widthThe actual text display area.Default to the widget display width if not filled.NOnumber
item_image_xitem Image x-coordinate, relative coordinatesNOnumber
item_image_yitem Image y-coordinate, relative coordinatesNOnumber
item_click_funcCallback for item click.NOItemClickFunc
item_focus_change_funcItem focus state callback.NOItemFocusChangeFunc

Data: object

PropertiesDescriptionRequiredType
srcThe path of image.NOstring
textThe content of text.YESstring

ItemClickFunc: function

(cycleList: CycleList, index: number) => void
PropertiesTypeNotes
cycleListobjectThe instance of cycleList.
indexnumberClicked item index.Starting from 0.

ItemFocusChangeFunc: function

(cycleList: CycleList, index: number, isFocus: boolean) => void
参数说明类型
cycleListThe instance of cycleList.object
indexLosing/getting the index of the focus item.number
isFocusWhether to get the focus.boolean

Set the properties of a single item text

caution

Setting the properties of a single item text is not stored by the widget and the changed values are not available via getProperty.

PropertiesDescriptionRequiredType
indexThe index of item.Starting from 0.YESnumber
item_text_colorThe color of the text.NOnumber
item_text_sizeThe size of the text.NOnumber
const widget = ...
widget.setProperty(prop.ITEM_MORE,{
index:0,
item_text_color:0x2f4988,
item_text_size:50
})

Refresh ITEM

  • This is set for the property ITEM_MORE. After setting the property with ITEM_MORE, you can refresh ITEM if you want to revert to its original state.
widget.setProperty(prop.ITEM_REFRESH, 0) // 0 is the index of item , starting from 0.

Set the top item index of the list

  • Set the index value of the top item of the list with the LIST_TOP property to display the list at the specified position of the item.
NameDescriptionRequiredType
indexThe index of item.Starting from 0.YESnumber

Code example

import { createWidget, widget, prop } from '@zos/ui'

const data_array = [
{ src: rootPath + 'step/step_num_0.png', text: '1' },
{ src: rootPath + 'step/step_num_1.png', text: '2' },
{ src: rootPath + 'step/step_num_2.png', text: '3' }
]
cycleList = createWidget(widget.CYCLE_IMAGE_TEXT_LIST, {
x: 0,
y: 0,
w: 200,
h: 400,
data_array: data_array,
data_size: 3,
item_height: 100,
item_bg_color: 0xffffff,
item_text_color: 0x000000,
item_text_x: 10,
item_text_y: 10,
item_text_size: 18
})

//Get the index value of the first row.
ret = cycleList.getProperty(prop.MORE, {})
console.log(ret.index)