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

Mashiane

Expert
Licensed User
Longtime 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)
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Row(3) and list are the same they inherits from Arraylist. Beyond the extra capabilities of the list There isn't much difference
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Also, row (3) has a finite size definition, while a list can be appended to, deleted from.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime 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).
 
Upvote 0
Top