Android Question List on Type Structure

FabioG

Active Member
Licensed User
Longtime User
Hello,

I have a problem
I need to do this

B4X:
Type AppSettings(ID As Int,IsDefault As Boolean,Model As String,LogEvent As List)
Dim Config as AppSettings
Config.LogEvent.Inizialize
Config.LogEvent.Add("Test1")

but I get this error message
B4X:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
how can I fix this?

Thanks!
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
    Dim Config As AppSettings
    Config.Initialize
    Dim l As List
    l.Initialize
    l.Add("Item1")
    l.Add("Item2")
    Config.LogEvent = l
 
Upvote 0

FabioG

Active Member
Licensed User
Longtime User
B4X:
    Dim Config As AppSettings
    Config.Initialize
    Dim l As List
    l.Initialize
    l.Add("Item1")
    l.Add("Item2")
    Config.LogEvent = l

thanks for your fast reply but it don't work

B4X:
Config.Initialize

I tired

B4X:
Config.LogEvent.Inizialize
Dim l AsList
 l.Initialize
 l.Add("Item1")
 l.Add("Item2")
 Config.LogEvent = l

but I get the same error

any ideas ?

Thanks
 
Upvote 0

FabioG

Active Member
Licensed User
Longtime User
i tried my code above and it works.

You need to initialize the type first. (see my code)
you can't use initialize on one of the typevalues.
Instead you should create a list by yourself and add the list to the fieldvalue (see my code again)

I'm sorry

yes, it works, thank you, I had forgotten to initialize

This will erase the previous contents of the list
any ideas to add to the previous contents?
 
Upvote 0
Top