Declaring subclasses

Tim Forrester

Member
Licensed User
Longtime User
I would like advise on how to use B4A for classes. I anticipate creating a class that will have a subclass (and the subclass will have a subclass). I have looked through many postings on the Online Community and Documentation and have not found a good example. My goal is to Initialize a new instance, update the instance variables with set methods, and save the content of the variables to a SQLite table.

The main class is a container (variables: container name, weight, size, etc.) that holds a collection of inner items of different types (variables: item name, weight, size, etc.) where the detail for each of the item types is defined in another class.

How do I tie this together in B4A code? Something like:

Class Container()
Class ItemCollection(Container)
Class Item(ItemCollection)

Sorry if this is a ignorant question. I have done only a little OOP and still learning.

Thanks.
 

Tim Forrester

Member
Licensed User
Longtime User
Basic4android doesn't support inheritance. So you cannot create subclasses. However you can create a common sub for each of your classes (SaveToDB) and then use CallSub to call this sub.

OK, welll still an excellent product. Thanks for the quick reply.
 
Upvote 0
Top