Android Question XUI development

Martin Larsen

Active Member
Licensed User
I am starting on a B4A - B4i cross platform project and I want to use XUI for this.

I have a few questions, though.

It is recommended in the video tutorials to move most of the code from the activity to a shared class module. But for multiple activities, should I use a new class module for each activity or use the same class module for all?

Is there a best-practice for naming the corresponding class modules? For example, with a prefix. For now, I have prefixed the class modules with xui. So Main is handled by xuiMain etc.

How do I finish an activity from the xui class module? Right now I have a sub in the activity and call it with CallSub, eg.
B4X:
CallSub(Splash, "Finish")
Is there a way to finish the activity directly?
 

Erel

Administrator
Staff member
Licensed User
It is recommended in the video tutorials to move most of the code from the activity to a shared class module. But for multiple activities, should I use a new class module for each activity or use the same class module for all?
It depends. If it makes sense to reuse the "component" in multiple activities then reuse the class. If not then create multiple classes. You can also use multiple classes in the same activity.
For example the drawer can be implemented in a class and reused in all activities and other stuff can be implemented in other classes.

Is there a way to finish the activity directly?
Not really. The only thing that I can add is that you can pass the "callback" object and use it instead of hard coding the activity name (relevant if the class can be reused with other activities).
 

Martin Larsen

Active Member
Licensed User
he only thing that I can add is that you can pass the "callback" object
What callback object? Do you mean the Parent parameter passed to Sub Initialize in the the class module?

B4X:
Public Sub Initialize(Parent As B4XView)
    Parent.LoadLayout("1")
End Sub
 
Top