Hi all. I searched a lot for this issue I'm having right now but, a part from the fact it's not easy to "clarify" it in a Google textbox, I found nothing.
I'm using a CustomListView that's a CustomView with designer support. The fact is I have to add a new CustomListView to a panel at run time.
I thought it wasn't a problem, but I'm getting a compile error when trying:
Public Sub Initialize (vCallback As Object, vEventName As String)
sv.Initialize2(0, "sv")
items.Initialize
panels.Initialize
dividerHeight = 2dip
EventName = vEventName
CallBack = vCallback
sv.Color = 0xFFD9D7DE 'this sets the dividers color
Dim r As Reflector
Dim idPressed As Int
idPressed = r.GetStaticField("android.R$drawable", "list_selector_background")
r.Target = r.GetContext
r.Target = r.RunMethod("getResources")
pressedDrawable = r.RunMethod2("getDrawable", idPressed, "java.lang.int")
DefaultTextColor = Colors.White
DefaultTextSize = 16
DefaultTextBackgroundColor = Colors.Black
DefaultTextBackground = Null
End Sub
With that code you could add the CustomListView to a Panel or to an Activity (vCallBack).
I don't know if adding this routine to the CustomListview you may have problems... try.
You may have a look at chapter 12.4 Custom views in the B4A User's Gude.
And especially chapter 12.4.2 Adding a custom view by code.
There you find an example of a CustomView which can also be added in the code.