ListView change item count – Fyne Golang GUI Tutorial

How to change item count in Fyne ListView?

item count

Source Code


package main
// import fyne
import (
    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/widget"
)
func main() {
    a := app.New()
    // window and title
    w := a.NewWindow("List View")
    // resize
    w.Resize(fyne.NewSize(400, 400))

    list := widget.NewList(
        // lets change item count 5
        func() int { return 5 }, // my list contain 5 items
        func() fyne.CanvasObject { return widget.NewLabel("I want to use label") },
        // last one
        func(lii widget.ListItemID, co fyne.CanvasObject) {
            // update data of widget
            co.(*widget.Label).SetText("Here is my text")
        },
    )
    // setup data on screen
    w.SetContent(list)
    w.ShowAndRun()
}

Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: