iOS Question Types do not match adding a B4xcombo

David Elkington

Active Member
Licensed User
Hi All, hope you are all having a nice day...

I am having an issue adding a combo to a panel on the fly, it gives an error 22 as below, and I can't work out what I am doing wrong. I can't seem to find a general reference to how things should be formatted. I realise that I am moving the object, I tried to fudge by adding in the designer and moving into position, but don't like that method.

B4X:
'Task Combo
            Dim query As String ="Select tsk_description from tasklist order by tsk_description"
            Dim lst As List
            lst.Initialize
   
            Dim rs As ResultSet
            rs = Starter.SQLstat.ExecQuery(query)
            lst.Add("Not Selected")
            lst.Add("Other")
           
            Do While rs.NextRow
                lst.Add(rs.Getstring("tsk_description"))
            Loop
           
            spnTask.Initialize(Me,"spnTask")
            spnTask.SetItems(lst)
           
            pnl.AddView(spnTask, 17%x, lngYPos, 45%x, 40dip)
            spnTask.mBase.Left = 100dip
            spnTask.mBase.top = lngYPos
            spnTask.mBase.Width=300dip
            spnTask.mBase.Height = 40dip
            spnTask.mBase.Visible = True

It is showing the error as below
1636541599224.png
 

Alexander Stolte

Expert
Licensed User
If you want to add a view from code, then you need the following steps:
B4X:
Dim MyCustomView As FourWayButton
MyCustomView.Initialize(Me,"EventName")
    
Dim xpnlBase As B4XView = xui.CreatePanel("") 'the view is built on this panel
xpnlBase.SetLayoutAnimated(0,0,0,40dip,20dip)
    
Dim xlbl As Label 'some custom views are using this label for properties from the designer
xlbl.Initialize("")
    
Dim PropMap As Map 'This is the Properties Map from the designer
PropMap.Initialize
PropMap.Put("CustomProp1","") 'look in the custom view to get the props with the right keys. These are located at the top and start with "#DesignerProperty".
    
MyCustomView.DesignerCreateView(xpnlBase,xlbl,PropMap)
 
Upvote 0
Top