Listview Image and Text and Switch

How to add a switch to your listview or make it look that way…

@Kleyber_Derick asked me if i had an idea how to add a switch to a listview. The listview should just have a Name and a Switch.

It is not possible to add a switch component inside the Listview but in the Listview Image and Text you can put an image. I choose to use two images.

switch-on-icon switch-off-icon

Then i used the following blocks to make everything work:

I use a separate list name itemchecked who keeps score of what image is used in the listview for every item.

When the value is 0 then it is switch-off-icon. If the value is 1 then it is switch-on-icon.

So now i can check and change the image of the item clicked with the update item block to get the following effect.

If you want you could store the itemchecked list in a TinyDB everytime something changes. So the switch positions could be saved this way and loaded when you start the app.

If someone wants to try here is the aia-file
listviewimagetextswitch.aia (16.3 KB)

8 Likes

@Peter if you want you could store the itemchecked list in a TinyDB everytime something changes. So the switch positions could be saved this way and loaded when you start the app.

can you make some block about this

Please help me "how to store tiny DB & When screen loaded again how to remove (stored) same element

Just store the variables in TinyDB. When screen initializes, set the variables to the values stored in TinyDB.

1 Like


what can i do now
I just want to remove when screen initialize every time

Can we have these images for our real Switches :joy:, @Peter is the guy for images, he chose the good ones lol

2 Likes

Thanks for this but do you know why they aren’t adding sizing options to switch? I really want to make it big.

Do not comment or make active on 3 years old topic…

Sorry but why not?