ListView change item count – Fyne Golang GUI Tutorial

How to change item count in Fyne ListView?

item count

Source Code

<div>package main</div>
<div>// import fyne</div>
<div>import (</div>
<div>    ""</div>
<div>    ""</div>
<div>    ""</div>
<div>func main() {</div>
<div>    a := app.New()</div>
<div>    // window and title</div>
<div>    w := a.NewWindow("List View")</div>
<div>    // resize</div>
<div>    w.Resize(fyne.NewSize(400, 400))</div>
<div>    list := widget.NewList(</div>
<div>        // lets change item count 5</div>
<div>        func() int { return 5 }, // my list contain 5 items</div>
<div>        func() fyne.CanvasObject { return widget.NewLabel("I want to use label") },</div>
<div>        // last one</div>
<div>        func(lii widget.ListItemID, co fyne.CanvasObject) {</div>
<div>            // update data of widget</div>
<div>            co.(*widget.Label).SetText("Here is my text")</div>
<div>        },</div>
<div>    )</div>
<div>    // setup data on screen</div>
<div>    w.SetContent(list)</div>
<div>    w.ShowAndRun()</div>
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: