BarryW Active Member Licensed User Longtime User Aug 6, 2018 #1 How to get a custom view from a panel or parent. 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
How to get a custom view from a panel or parent. 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
klaus Expert Licensed User Longtime User Aug 6, 2018 #2 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) Upvote 0
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)
Erel B4X founder Staff member Licensed User Longtime User Aug 6, 2018 #3 klaus said: cv as AutoTextSizeLabel = Panel.GetView(0) Click to expand... 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: Code: Copy mLBL.Tag = Me This allows you to get it with: Code: Copy Dim cv As AutoTextSizeLabel = Panel.GetView(0).Tag Upvote 1
klaus said: cv as AutoTextSizeLabel = Panel.GetView(0) Click to expand... 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: Code: Copy mLBL.Tag = Me This allows you to get it with: Code: Copy Dim cv As AutoTextSizeLabel = Panel.GetView(0).Tag
klaus Expert Licensed User Longtime User Aug 6, 2018 #4 Sorry, I reasoned like a 'standard' view. Upvote 0