Android Question Adding Class module at Runtime

JamesGreaves

Active Member
Licensed User
I have downloaded and run the custom class module, NumUpDown. Which runs fine when added to a layout through the Designer. However I am struggeling to add it at Runtime.
This is what I have done:

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")

Dim NUD As NumUpDown

NUD.Initialize (NUD,"NUD")
NUD.Value=5
NUD.Minimum=0
NUD.Maximum =10

Activity.AddView(NUD,10,10,200,50) <<<< ERROR: Types do not match(Warning #22)

End Sub

Seams I have to change "NUD as NumUpDown" into a "View".
Is that right, and if so how do I do this?
 

Attachments

  • Modified NumUpDown.zip
    8.2 KB · Views: 237
  • Modified NumUpDown.zip
    8.2 KB · Views: 210

Cableguy

Expert
Licensed User
Longtime User
There should be a "addToParent" method
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
As Cableguy said, you need to add an AddToParent routine in the class code.
Attached a modified version.
You may have a look at the B4A User's Guide chapter 12.4 Custom views.
And especially chapter 12.4.2 Adding a custom view by code
 

Attachments

  • Modified NumUpDown1.zip
    8.5 KB · Views: 261
Upvote 0
Top