I created a layout with a customview. Then I try to load the layout inside a panel. How to get the customview now? like dim cv as custoview = Panel.GetView(0).
I got this error..
java.lang.ClassCastException: anywheresoftware.b4a.BALayout cannot be cast to com.napps.stl.customview
What CustomView do you use?
You must declare it with its name.
If your CustomView is, for example, AutoTextSizeLabel, you must write this:
cv as AutoTextSizeLabel = Panel.GetView(0)
This will not work. The custom view class is not a view by itself.
A simple way to solve it is by setting the Tag property of the base panel or in the case of AutoTextSizeLabel the Label (the base panel is removed) to the class instance in DesignerCreateView:
B4X:
mLBL.Tag = Me
This allows you to get it with:
B4X:
Dim cv As AutoTextSizeLabel = Panel.GetView(0).Tag