I've been going over this for some time but just can't seem to figure it out.
I keep getting an IndexOutOfBoundsException for the MainList (index is 40, size is 40).
Here is some background on the app:
I have a scrollview with a bunch of buttons, and I want to let the user hide buttons if they choose. Now, in the above code, if I change the line to MainList.Size-2, then the code works almost perfectly. The problem is that you can't hide the very last button. If you try nothing happens and the button remains on the screen.
Here is the code I am using to hide the buttons:
I'm sure it's something very obvious, but I've been staring at it for far too long. Any help would be great.
B4X:
Sub UpdateMainList
If File.Exists(File.DirInternal,"HideList.txt") = True Then
HideList = File.ReadList(File.DirInternal,"HideList.txt")
Dim Hidden As String
Dim i As Int
Dim n As Int
For i = 0 To HideList.Size-1
Hidden = HideList.Get(i)
For n = 0 To MainList.Size-1
If Hidden = MainList.Get(n) Then
MainList.RemoveAt(n)
End If
Next
Next
End If
End Sub
I keep getting an IndexOutOfBoundsException for the MainList (index is 40, size is 40).
Here is some background on the app:
I have a scrollview with a bunch of buttons, and I want to let the user hide buttons if they choose. Now, in the above code, if I change the line to MainList.Size-2, then the code works almost perfectly. The problem is that you can't hide the very last button. If you try nothing happens and the button remains on the screen.
Here is the code I am using to hide the buttons:
B4X:
Sub Button_LongClick
Dim Send As Button
Dim MsgHide As Int
Send = Sender
MsgHide = Msgbox2("Hide Button?","","Yes","","No",Null)
If MsgHide = DialogResponse.NEGATIVE Then
Return True
Else
HideList.Add(Send.Text)
File.WriteList(File.DirInternal,"HideList.txt",HideList)
ClearButtons
UpdateMainList
CreateButtons
End If
End Sub
I'm sure it's something very obvious, but I've been staring at it for far too long. Any help would be great.