2 回答

TA贡献1831条经验 获得超9个赞
如果人们正在寻找解决方案,我只想提供一些示例代码。
func someListCreationMethod(data []string) *widget.List {
return widget.NewList(
func() int {
return len(data)
},
func() fyne.CanvasObject {
return container.NewPadded(
widget.NewLabel("Will be replaced"),
widget.NewButton("Do Something", nil),
)
},
func(id widget.ListItemID, item fyne.CanvasObject) {
item.(*fyne.Container).Objects[0].(*widget.Label).SetText(data[id])
// new part
item.(*fyne.Container).Objects[1].(*widget.Button).OnTapped = func() {
fmt.Println("I am button " + data[id])
}
},
)
}
- 2 回答
- 0 关注
- 218 浏览
添加回答
举报