B4J Question List1.Add error

Put Claude

Active Member
Licensed User
In B4J
If Lgpgsv1.Size < 20 Then Lgpgsv1.Add("0") will give the error 'java.lang.UnsuportedOperationExeption'
Lgpgsv1.Add("0") also will give the error 'java.lang.UnsuportedOperationExeption', so I think this is the devil,
I cannot add anything to the list.

Put Claude Belgium
 

Put Claude

Active Member
Licensed User
Dim sf As JStringFunctions 'in Process_Globals, maybe the use of this lib causes the problem
'......
'extract the items of this string to a list
Lgpgsv1.Initialize
Lgpgsv1= sf.Split(newstr,",") 'splitt all items into a list
If Lgpgsv1.Size < 20 Then Lgpgsv1.Add("0") 'uphere I got the error

'--------------------------------------
'I did a workaround like this:
'extract the items of this string to a list
Lgpgsv1.Initialize
Lgpgsv1= sf.Split(newstr,",") 'splitt all items into a list
If Lgpgsv1.Size < 20 Then newstr = newstr & "0"
Lgpgsv1.Initialize 're-initialize
Lgpgsv1= sf.Split(newstr,",") 'again splitt all items into a list
 

Daestrum

Well-Known Member
Licensed User
Looks like if you use
B4X:
myList = sf.split(??,",")
you get the error
If you change it to
B4X:
myList.AddAll(sf.split(....))
you can then add things to the end of the list.
Think you have been caught by java reference to object in this case the sf list has a definite size, it wont let you extend it, and using
mylist = sf.split(...) you set your list as a reference to the sf list.
 

Put Claude

Active Member
Licensed User
Thanks a lot
Problem solved

Lgpgsv1.Initialize
Lgpgsv1.AddAll(sf.split(newstr,","))
If Lgpgsv1.Size < 20 Then Lgpgsv1.Add("0")

'now I can add to the list
Thanks again!!!

Put Claude Belgium
 
Top