Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grid Layout Vs. Table Layout

I am working on a booking engine android app like an airline booking system. To fetch the content of say all the available airlines specific to a passenger search, this is then displayed on the mobile's screen.

Which one, a table layout or a grid layout, will be effective considering screen loading time, system memory consumption, and additional features?

like image 368
learn_andrd Avatar asked Aug 17 '11 06:08

learn_andrd


People also ask

What is the difference between table and grid layout?

With the TableLayout , rows and columns are added dynamically as you build the table. With the GridLayout , row and column sizes are defined in the layout definition. Neither layout is better, it's just a matter of using the best layout for your needs.

Is grid same as table?

People usually talk about a "table" of information (numbers, with labels describing them). A "grid" is the arrangement. For example, in an Excel spreadsheet "the grid" is the lines. The information you put there is a "table".

Should I use table or grid?

The focus on user interaction means that Data Grids often support more selection options than a Data Table. A Data Table may allow row selection for copy and pasting data. Data Grids often allow discontiguous row and cell selection and range selection to feed into more advanced functionality.


2 Answers

**EDIT: This line was correct when this answer was written, but no longer applies to 99.9%+ of all Android devices: There is no GridLayout in the Android API. **

(Note: As of API level 14, there finally is GridLayout; see the answers below. In addition, the V7 support library adds GridLayout support down to API 7. However, this answer's description of GridView is still accurate and very well stated.)

If you mean GridView, TableLayout and GridView are completely different things.

A GridView is basically like a ListView but whose items are arranged in a strict grid. It is attached to an Adapter, and retrieves views from the Adapter has the user scrolls through it. All elements in the grid must be the same size. The user can move a visible selector through each item -- the goal of a GridLayout is to display the data from an Adapter and let the user navigate and select each of the displayed items. The only difference from a ListView is that the items are put in a grid instead of in a vertical list.

TableLayout is just a layout manager, somewhat like a table in HTML. It does not itself do any scrolling; to have something that scrolls you must put the TableLayout in a ScrollView. This implies that all of the data you are displaying must be populated into the TableLayout up-front, so the ScrollView knows the total space it is to scroll in. It also does not directly give you per-"item" selection or interaction, because a TableLayout doesn't have items, it is just a layout manager.

You didn't actually give near enough useful information about what you are actually trying to do for anyone to recommend what to use. It depends a lot on what specifically you want.

I mean what will be useful in terms of "additional features"?!? Well what features are you looking for!

Anyway as a general rule, an Adapter-based view should be used for any situation where you have a significant amount of data that the user is scrolling view; these are a lot more efficient than having to create the entire view hierarchy up-front to display your data. They are also the only ones that automatically provide per-item selection and other such features. The primary view for this that applications use is ListView, though GridView can also be used.

like image 79
hackbod Avatar answered Sep 17 '22 20:09

hackbod


Since android 4.0, there is such a thing as a GridLayout. GridLayout is always preferable to TableLayout. It provides all that you already have on TableLayout, and can replace other layouts too.

It seems quite cool, and it seems that Google wish it to be as popular as the LinearLayout (according to their videos of Android 4.0).


EDIT: if you have to show a lot of items, consider using RecyclerView with GridLayoutManager. This can help in terms of memory and CPU usage.

like image 23
android developer Avatar answered Sep 18 '22 20:09

android developer