Android Question BCCodeView in class Code

Gianni Sassanelli

Active Member
Licensed User
Longtime User
Hi
I'm trying to build a class using BCCodeview.
The class is very simple and contains this hierarchy:
PANEL
BUTTON (view 0)
LABEL (view 1)
BCCCodeview (view 2)

I have created a Show method in which I retrieve the views to use them as needed.

--Classcode Initialize
B4X:
Sub Class_Globals
    Dim vBox                         As B4XView
End Sub


public Sub show(root As B4XView)
root.AddView(vBox,30dip,100dip,100%x - 60dip,100%y -200dip)
vBox.LoadLayout("mylayout")   ' my lyaout contains 1 button, 1 label, 1 BBCodeView

'here i want to retrieve the view that are saved into layout but unsuccessfully
'the code is:
dim btn as Button = Panel.getview(0).As(Button)   ' all rights
dim lbl as Label = Panel.getview(1).As(Label)         ' all rights
Dim BCCV AS BCCCodeview = Panel.getview(2).As(B4xView).Getview(0).As(BCCCodeview)    ' KO this is the problem
'......
End Sub


Could I have some help, please?
 

William Lancee

Well-Known Member
Licensed User
Longtime User
Custom view objects are accessed through the tag of their base panel

B4X:
    Root.LoadLayout("MainPage")
    Log(Root.NumberOfViews)
    Dim pnl As B4XView = Root.GetView(0)
    Dim cvBase As B4XView = pnl.GetView(0)
    Log(GetType(cvBase.Tag))
    
'    1
'   b4j.example.bbcodeview
 
Upvote 1
Top