I am storing entries in a string with : as a separator. The string is split into a list and can be viewed and individual items slected from an inputlist.
To add items to the list I use the code below. On its first execution an exception appears:
main_bu_fav_longclick (B4A line: 1960)
slist.Clear
java.lang.UnsupportedOperationException
at java.util.AbstractList.remove(AbstractList.java:645)
at java.util.AbstractList$SimpleListIterator.remove(AbstractList.java:77)
at java.util.AbstractList.removeRange(AbstractList.java:665)
at java.util.AbstractList.clear(AbstractList.java:473)
at anywheresoftware.b4a.objects.collections.List.Clear(List.java:66)
at xxx.xxx.main._bu_fav_longclick(main.java:1294)
Also an "slist.add("CCCC") at the same place as "slist.clear" throws the same exception.
When I call the code a second time and for all subsequent times the code works ok.
What's wrong here?
To add items to the list I use the code below. On its first execution an exception appears:
main_bu_fav_longclick (B4A line: 1960)
slist.Clear
java.lang.UnsupportedOperationException
at java.util.AbstractList.remove(AbstractList.java:645)
at java.util.AbstractList$SimpleListIterator.remove(AbstractList.java:77)
at java.util.AbstractList.removeRange(AbstractList.java:665)
at java.util.AbstractList.clear(AbstractList.java:473)
at anywheresoftware.b4a.objects.collections.List.Clear(List.java:66)
at xxx.xxx.main._bu_fav_longclick(main.java:1294)
Also an "slist.add("CCCC") at the same place as "slist.clear" throws the same exception.
When I call the code a second time and for all subsequent times the code works ok.
What's wrong here?
B4X:
'edwx defined as edittext above
Dim wxlist as string : wxlist="AAAA:BBBB"
Sub bu_fav_longclick 'Add a favorite
Dim i,j As Int
Dim slist As List
slist.Initialize
If wxlist.Length=0 Then
wxlist=edwx.Text
Return
End If
slist=Regex.Split(":",wxlist)
i=slist.IndexOf(edwx.Text)
If i>-1 Then
Return
End If
wxlist=wxlist&":"&edwx.Text
slist.Clear
slist=Regex.Split(":",wxlist)
slist.Sort(True)
wxlist=""
j=slist.Size-2
For i=0 To j
wxlist=wxlist&slist.Get(i)&":"
Next
wxlist=wxlist&slist.Get(slist.size-1)
End Sub
Last edited: