I made a long layout CellItem which has Label1 and CustomListView1. The layout script has DDD.CollectViewsData.
I can access Label1 using
But, I can't access CustomListView1 using
I am getting error:
Can you please help? Below is the full code:
I can access Label1 using
B4X:
dd.GetViewByName(p, "Label1").Text = Text
But, I can't access CustomListView1 using
B4X:
Dim my_clv As CustomListView = dd.GetViewByName(p, "CustomListView1").Tag
my_clv.Clear
I am getting error:
B4X:
Error occurred on line: 256 (DDD)
java.lang.IllegalArgumentException: field b4a.example.b4xmainpage._my_clv has type b4a.example3.customlistview, got java.lang.String
Can you please help? Below is the full code:
B4X:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private clv2 As CustomListView
Private dd As DDD
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
dd.Initialize
'The designer script calls the DDD class. A new class instance will be created if needed.
'In this case we want to create it ourselves as we want to access it in our code.
xui.RegisterDesignerClass(dd)
Root.LoadLayout("MainPage")
clv2.Add(CreateListItem("my text", clv2.AsView.Width, 1150dip), "mypage")
End Sub
Private Sub CreateListItem(Text As String, Width As Int, Height As Int) As B4XView
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, Width, Height)
p.LoadLayout("CellItem")
'Note that we call DDD.CollectViewsData in CellItem designer script. This is required if we want to get views with dd.GetViewByName.
dd.GetViewByName(p, "Label1").Text = Text
Dim my_clv As CustomListView = dd.GetViewByName(p, "CustomListView1").Tag
my_clv.Clear
Return p
End Sub