B4J Question TableView: To 'Object' or To 'List' - that is the question

Mashiane

Expert
Licensed User
Hi there

I have been using the 'Dim row(3) As Object' notation for a while with tableviews record addition. So I decided to try to use a list instead.

So I..

B4X:
Dim row as List
row.Initialize
row.add("x")
row.add("y")
row.add("z")
tableview.items.add(row)

of rather row.AddAll(array as string("x","y","z"))
Obviously it works. Question is, whether is it better to use () As Object than a List and whether there is anything significant in using a List or is just a preference issue to use Object/programming style. Yes defining a List needs the additional steps in initializing it and then calling .Add for each or .AddAll (this is doing the same thing anyway)
 

OliverA

Expert
Licensed User
My 2 cents. If the list that you add to the TableView has to be generated dynamically, if the list needs to change, or if the list is used for other purposes (other TableViews? Lookup? etc.), then use a list. But if it's just static, the items don't change, and you don't have multiple uses for the "list", then there is nothing wrong with just using the Array As option. For plain one shot static "list" of items, creating a list, initializing, and adding members seems to be a lot of extra typing. In other words, it depends (a common theme in programming).
 
Top