Skip to main content
Version: v1.0

CYCLE_LIST

cycle_list_sample

Create a list that scrolls in a loop, which can be populated with images.

Create UI widget

const cycleList = hmUI.createWidget(hmUI.widget.CYCLE_LIST, Param)

Type

Param: object

PropertiesDescriptionRequiredType
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_click_funcCallback for item click.NOItemClickFunc

ItemClickFunc: function

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

Code example

tip

Please refer to Design Resources for the image resources in the code example

Page({
state: {
pageName: 'CYCLE_LIST'
},

build() {
const imgArray = ['number-img/0.png', 'number-img/1.png', 'number-img/2.png', 'number-img/3.png', 'number-img/4.png']
const cycleList = hmUI.createWidget(hmUI.widget.CYCLE_LIST, {
x: 230,
y: 120,
h: 300,
w: 30,
data_array: imgArray,
data_size: 5,
item_height: 100,
item_click_func: (list, index) => {
console.log(index)
},
item_bg_color: 0xffffff
})
}
})