Search object in listview and remove

Hi,

I have build a widget that includes a listview.
This listview contains widgets that are constructed and added to this listview.
Here is an overview of how that looks like:

Everytime the player hits a specific button, a new widget is constructed and added to this listview with different text inside of it (textblock’s seen in this image).

Now I would like to search a text inside of this specific list and remove that it.

Do I have to reconstruct the object? It would be really helpful to see an example.
Many thanks!

you first need to hold all the entries inside an array in your widget, as variable.

when the player hits the add button, add the new entry to the array.

you then create an update function, that clears all children from the list and then populates it new by foreach looping the array and add each entry to the list. Make sure to add the entry data to the list item, too, so each list items knows what its content is.

now…
when you want to search for a specific text, you ask the array if it contains that text, get the index of the item and removeAt that index. And recall the update function again.

if you want to delete entries by clicking on the list item… add a button to each item, that talea the listItem holded data and again removes it from the array by searching the index of that specific one… and rerun the update function…

1 Like