Android Question SetOnClickListener

b4auser1

Well-Known Member
Licensed User
Longtime User
Is it possible to tell Reflector, which module holds the Sub, to be called after setting it in the SetOnClickListener ?
 

corwin42

Expert
Licensed User
Longtime User
Upvote 0

b4auser1

Well-Known Member
Licensed User
Longtime User
15.png
Reflector.SetOnClickListener (sub As String)
- has only one parameter sub As String. How to pass the name of module where the Sub is located ?
Now As I can see the Sub has to be in the same module where SetOnClickListener (sub As String) is called.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
If you are using a class then the initialize sub would capture the module then you can use CallSub(module,sub) to redirect it.
 
Upvote 0

b4auser1

Well-Known Member
Licensed User
Longtime User
stevel05,

yes I used this approach, but wanted to know if it's possible to do the same directly with Reflector
B4X:
            Dim r As Reflector
            r.Target = a_AB_btn
            r.SetOnClickListener("AB_btn_Click")

Private Sub AB_btn_Click(ViewTag As Object)
    If SubExists (Module, ViewTag) Then
        CallSub(Module, ViewTag)
    End If
End Sub
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
No, but the upside is there are times that you may want to pre-process the data or do something else such as hiding a view, before passing it to the module that calls it.
 
Upvote 0
Top