Android Question Class & Events

luke2012

Well-Known Member
Licensed User
Longtime User
Hi to all,
I'm writing a class where I initialize some panels (private).
How I can handle the panels events (like _Click) within the Activity where I initialize the class?

Thanks in advance! :)
 

luke2012

Well-Known Member
Licensed User
Longtime User
I see.
So the code that link to the activity module is the following :

1) Code in the Class:

private sub panel1_click ()
'Statments...
end sub

If SubExists(Main, EventName & "_Click") Then
CallSub3(Main, EventName & "_Click", par1, par2)
End If

2) Main module (where the class is initialized):

How should be defined the signature name in this module?
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
This is how I usually do it:

B4X:
Sub Class_Globals
    'Class Variables
    Private mModule    As Object 
    Private mEventName As String 
    ....

Public Sub Initialize(pModule As Object, pEventName As String)
    mModule    = pModule
    mEventName = pEventName
End Sub

Private Sub RaiseEventValueChanged(UserChanged As Boolean)
    If SubExists(mModule, mEventName & "_ValueChanged") Then
        CallSubDelayed3(mModule, mEventName & "_ValueChanged",seekValue, UserChanged)   
    End If
End Sub

and in Main:

...somewhere...

B4X:
....
Dim s As SuperSeekbar 
s.Initialize(Me, "s")
....

Sub s_ValueChanged(Value As Double, UserChanged As Boolean)
    lbl.Text = NumberFormat(Value, 1,2)
End Sub
 
Upvote 0
Top