B4J Question Tableview1.RemoveAt(index) deletes 2 rows

le_toubib

Active Member
Licensed User
Longtime User
hi falks
this code results in deleting 2 rows rather than 1 :
B4X:
Sub Button_Click
'This button exists in a cell in the row to be deleted
    Dim b as Button = Sender
    Dim RowID as int = b.Tag
    DeleteRow(RowID)
End Sub

Sub DeleteRow(RowID as int)
    Tableview1.RemoveAt(RowID)
End Sub
-i Found old posts on the forum but solutions didn't work.
-P.S: I know bxtable is a lot better , but i can't use it in this project
thanks
 

le_toubib

Active Member
Licensed User
Longtime User
thanks erel ..
B4X:
Sub DeleteRow(RowID as int)
    Tableview1.RemoveAt(RowID)
    List1.RemoveAt(RowID)  '  <------ this global list (of maps) was made while filling the table ... 
End Sub
removing this line solved the problem , however i don't know why ??? it's not identical to table items, as it's a list of maps , not of arrays..
 
Upvote 0

MegatenFreak

Active Member
Licensed User
The exact same thing happened to me in a specific page in my project, and a single RemoveAt seemed to remove two rows at once.
BUT, strangely, it only SEEMED to remove two; the second row would disappear visually, but it was still there, and it 'reappeared' when I added a new row!
It only happened with a certain number of rows: when I deleted row 2, row 3 would also disappear, but it came back once a 4th row was added.
I could never solve the issue. Instead I chose to rebuild the entire table after a delete action. I reckon it's a weird subtle bug in Java.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…