Listview Image and Text and Switch


#1

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)


(digital tech360) #2

@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


(digital tech360) #3

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


(Kanishka Chakraborty) #4

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


(digital tech360) #5


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


(Nathan) #6

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