Deleting Item from List on Thunkable X

listview
beginner

#1

I’m getting an issue with deleting items. The index it seems to select, and therefore delete, is always the one at the top of the list as seen in the screenshots here:

** I was pressing the item at the very bottom (A)

And here’s my codeblock:
image
It would be really helpful to receive your input on this. Thank you!


#2

An example works well for me.


#3

No, I jumped to review. I see the oddity. If to remove in this order ADB, then C can only be removed when re-pressing it. When you first click on the remaining C, it is not removed! One remaining item in the list is not deleted the first time.

https://x.thunkable.com/projects/5bfece2f2ceade68e43fab5b/project/properties/designer/


#4

I believe the problem is that you are modifying the List_Viewer2.TextItems and hoping that it will correctly modify the List_Viewer display. You need to explicitly set the List_Viewer2.TextItems property to correctly redisplay the List Viewer. See the following for a updated version of @actech’s example: https://x.thunkable.com/copy/c1d586b791dc3322b90de618f1eddf67

-Mark


#5

No, there is still an issue with removing items from a listviewer. Here is my example, trying to carefully implement Mark’s suggestion:
https://x.thunkable.com/copy/f3d0699f05bb8cc370ba9fd715ee759c

It still deletes the item below the selection on screen2. Also, you can’t delete the last item. Is this a bug in the List or the listviewer?


#6

Is this only works with simple lists like that?
what about complex lists with multiple columns, i.e. multiple properties (ID, first name, last name, address…) for the same object (list item).
I’ve been having troubles for a long time removing the whole item from a local.


#7

What I meant earlier, in this example, the path leads me to a a list of 3 items containing two properties: Question and Answer, as you can see in the first screenshot.

Then if I want to know if the list has been stored I ask for the length of the list, which is 3; however if I try to display the list in the listviewer, the app crashes everytime. (second screenshot)

image

Do you think this could be the reason why I am having troubles removing items from lists properly?

FYI: in the last screenshot, 1) the reason behind why to find first and then remove was because it worked like that for another user having issues removing items from lists, however idk if his lists are like mine; 2) the reason why I use the variable “app discard” and then sustract 1, is because on that list I have another property which is a sequential number for all the items in my list, so I sustract 1 simulating the index number of that item on the list.


#8

I didn’t read to your complete code but yesterday I experienced similiar issues if the index you want to remove is 0 (even though the list counter starts at 1). I expected that in this case the “in list remove” command would not remove any item in the list. I’m pretty sure thas this behaviour is not intended.
I used it in combination with “find first occurence of item”.

Example: https://x.thunkable.com/copy/7edfd4588c78b1ec2d52ba5c62a8177b


#9

I used your blocks with my own list downloaded from realtimedb (just as my original app), and you are right, when the list item (either original or the new one resulting from the removing of items) is now index 0, it is “removed” from the length of the list, but it is still displayed on the labels, hence… duplicated results in the get random.