Events in activies <> classes

kanaida

Active Member
Licensed User
Longtime User
Hey guys, i'm starting to build a 'control/view', pretty simple. It's just a panel with an image, label and button. A polaroid photo shape. However, I want it to be reusable, meaning let the class generate the panel with the views... BUT, let the activity handle the button.click(), because I may reuse that user view/control from many different activities to do a number of different things.

In vb.net I'm used to just doing this:
B4X:
MyClass
 Public Event ButtonClicked

 Sub Button1_Click()
    RaiseEvent(Me,EventArgs)
 End Sub

End MyClass

'Then in my activity I'd just add a handler and be done with it.

[Activity]
Sub Activity_Create(FirstTime As Boolean)
 'If it worked, something like this
   Dim x as Polaroid
   x.initialize(Me,"polaroid")

 'or vb style:
 Addhandler x.Click, Polaroid_Click
End Sub

Sub Polaroid_Click(sender as object, EventArgs as object)
'Do what my activity wants
End Sub

Any way I can do this? It would mean no duplicate code and simulated user controls in my case.
 
Last edited:

drachmad

Member
Licensed User
Longtime User

Attachments

  • ClassNonModal.zip
    8 KB · Views: 201
Last edited:
Upvote 0
Top