Hi,
I've done a class to improve and standarize my list views
Into an Activity, I've defined a PanelView so that class does fill the views that I like into the Panel
One of these views is a button to close the activity
If into the class I do a call to a sub into that Activity, for doing an Activity.Finish all is fine
But, I'm looking for a way to do that without define any sub into the Activity
Is there a way to close an activity from a class?
Thanks
You will need to pass the activity as an argument when initializing the class
This is an example of a class module that will close the activity after a timeout
B4X:
'Class module
Sub Class_Globals
Dim myp As Activity
Dim t As Timer
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(Parent As Activity,temps As Long)
myp=Parent
t.Initialize("T1",temps)
t.Enabled=True
End Sub
Sub T1_Tick
t.enabled=False
CallSubDelayed(Me,"closeActivity")
End Sub
Sub closeActivity
myp.Finish
End Sub
and from your main module
B4X:
Dim CL1 as CL_test 'the name of the class
...
CL1.Initialize(Activity,5000)