Android Question [SOLVED] If you define as list as Dim lst As List = array as string("a", "b", "c"), why cant you run lst.add("d")?

Mashiane

Expert
Licensed User
Longtime User
Ola

for some reason unknown my code is running an exception when I create a list like

B4X:
Dim flds As List = Array As String("msgtopic", "msgtitle", "msgbody", "msgdeviceid", "msgtype", "msgdate", "msgtel1", "msgtel2", "msglat", "msglon", "msgseqnumber", "messageid")

and then try and execute a

B4X:
flds.add("x")

into it

What am I missing?

1612495968749.png


When does this happen?

My app is not running and I click a notification, the app gets activated, the error happens, however as soon as I remove the flds.add("x") on the code, everything works well.
 

Star-Dust

Expert
Licensed User
Longtime User
Ola

for some reason unknown my code is running an exception when I create a list like

B4X:
Dim flds As List = Array As String("msgtopic", "msgtitle", "msgbody", "msgdeviceid", "msgtype", "msgdate", "msgtel1", "msgtel2", "msglat", "msglon", "msgseqnumber", "messageid")

and then try and execute a

B4X:
flds.add("x")

into it

What am I missing?

View attachment 107447

When does this happen?

My app is not running and I click a notification, the app gets activated, the error happens, however as soon as I remove the flds.add("x") on the code, everything works well.
You have assigned a non-resizable Array to the list. Now you can't add anything to the list.

Do not assign an Array to the list but use AddAll method
 
Upvote 0
Top