B4J Question Can a class module receive events?

Midimaster

Active Member
Licensed User
at the moment I try to create an extented version of ListView in a class SortExpandListView. Therefore I defined a CustomListView in Main as a class internal:
B4X:
'in main:'
Private clv1 As CustomListView, Listview As SortExpandListView
...
Sub AppStart ()
     MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    Listview.Initialize(clv1)
    
'and in class:'
    Private mCLV As CustomListView
...
Public Sub Initialize (CLV As CustomListView)
    mCLV=CLV
End Sub

At the moment I handle the Events in the MAIN module and forward them to the class:
B4X:
'in main:'
Listview.Initialize(clv1)
...
Private Sub lblTitle_MouseClicked (EventData As MouseEvent) ' a view in the clv1
    Listview.OpenItem(Sender)
End Sub

'and in class:'
Public Sub OpenItem(lbl As B4XView)
    Dim index As Int=mCLV.GetItemFromView(lbl)
    ...

Now my question is: can I modify the class, so that mCLV directly receives the events?
 

Midimaster

Active Member
Licensed User
ListView in this context only means something like a "list view". Only when bold I talk about B4X-Views. My word ListView in the code is also only a variable name. Like you also can talk about buttons (outside in real life) without meaning the Button-View of B4X

Of course I use xCustomListView only! ;)


... You should move the label to the class and handle its events there....
this is axactly what i need to know: How to "move" a label or a loading of a layout into the class. Perhaps somebody points me to the right way or has a code snipplet for me.
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
The easiest way would be to wrap the Customlistview as your own customview if the main purpose is to extend the CLV.
 
Upvote 0
Top