add listview
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
export default [
|
||||
'src/Counter',
|
||||
'src/Snake',
|
||||
'src/ListDemo',
|
||||
]
|
26
demo/src/ListDemo.ts
Normal file
26
demo/src/ListDemo.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, ListItem } from "doric";
|
||||
|
||||
@Entry
|
||||
class ListPanel extends Panel {
|
||||
build(rootView: Group): void {
|
||||
const list = new List
|
||||
list.layoutConfig = {
|
||||
widthSpec: LayoutSpec.AT_MOST,
|
||||
heightSpec: LayoutSpec.AT_MOST,
|
||||
}
|
||||
rootView.addChild(list)
|
||||
list.itemCount = 10
|
||||
list.bgColor = Color.parse("#ff00ff")
|
||||
list.renderItem = (idx) => {
|
||||
const item = new ListItem
|
||||
item.addChild(text({
|
||||
width: 100,
|
||||
height: 100,
|
||||
text: `第${idx}行内容`,
|
||||
textAlignment: gravity().center(),
|
||||
}))
|
||||
return item
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user