I Indy Active Member Licensed User Longtime User Sep 30, 2020 #1 Hi Folks, Quick question - Is it possible to cast a generic Object to a View? I want to convert a generic object to a view which is based on a value from a database table. For example; B4X: Dim ob As Object Dim cbox as CheckBox if val="cb" then ob = cbox ob.Initialize("") etc.... end if The reason I'm doing this is because I'm building a config screen, which will read values from a table in an SQlite database and dynamically create views and set their values. I'd prefer not to hardcode the views as these may change over time. Thanks
Hi Folks, Quick question - Is it possible to cast a generic Object to a View? I want to convert a generic object to a view which is based on a value from a database table. For example; B4X: Dim ob As Object Dim cbox as CheckBox if val="cb" then ob = cbox ob.Initialize("") etc.... end if The reason I'm doing this is because I'm building a config screen, which will read values from a table in an SQlite database and dynamically create views and set their values. I'd prefer not to hardcode the views as these may change over time. Thanks
LucaMs Expert Licensed User Longtime User Sep 30, 2020 #2 You could use a B4XView instead of an object. B4X: Dim MyView As B4XView if val="cb" then Dim cbox as CheckBox cbox.Inizialize("") ' <--- "cbox"? MyView = cbox etc.... end if Upvote 0
You could use a B4XView instead of an object. B4X: Dim MyView As B4XView if val="cb" then Dim cbox as CheckBox cbox.Inizialize("") ' <--- "cbox"? MyView = cbox etc.... end if
I Indy Active Member Licensed User Longtime User Sep 30, 2020 #3 LucaMs said: You could use a B4XView instead of an object. B4X: Dim MyView As B4XView if val="cb" then Dim cbox as CheckBox cbox.Inizialize("") ' <--- "cbox"? MyView = cbox etc.... end if Click to expand... You Sir have saved the day - Worked like a charm. Thank you for your help. Upvote 0
LucaMs said: You could use a B4XView instead of an object. B4X: Dim MyView As B4XView if val="cb" then Dim cbox as CheckBox cbox.Inizialize("") ' <--- "cbox"? MyView = cbox etc.... end if Click to expand... You Sir have saved the day - Worked like a charm. Thank you for your help.