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 關注
- 193 瀏覽
添加回答
舉報