Arsen Gyulgazyan Arsen Gyulgazyan - 7 months ago 53
Java Question

What is the best way to create a data table in android?

I would like to create a table which is filled by data from DB. I know that it is possible to create a dynamic table using TableLayout but I'm not sure that it's the best solution im my case.

Here is an example of what I want to create(the first table on the page).


I'll give you my inputs on this.

If your data is limited and you are sure to display all of it in a single screen in a presentable manner, then yes, a TableLayout will suffice.

However, in a real world, flexibility counts so you should always consider the possibility that your data may expand in the future. Keeping that in mind, you should use a ListView or a RecyclerView in this case. Define a base layout for each row of your list or recycler view and then connect the data from your database to this view using a suitable adapter.

For starters: