I am an Android newbie and I am wondering what to do regarding a big table I want to display.
Currently I am testing a TableLayout with 100 TableRows. The final table will have much more rows, in the order of the thousands.
Since TableLayout is a View, I wonder what is the correct, or recommended, approach in this case. To use a View (TableLayout) containing all the data I have, or dynamically add/delete rows in the viewable window, as the user scrolls up and down.
What are the pros and cons of the different approaches? Examples?
The clearest disadvantage to having them all on screen at the same time is that the OS essentially has to have all of your thousands of View objects in memory at the same time - VERY expensive, memory-wise.
On the other hand, creation and destruction of views as you scroll is processor intensive and slows down the UI considerably.
The primary alternative (and the one that android uses in its
ListView control (Which is probably what you should use instead, by the way), is to only create enough views to fill the screen (plus a little padding on either side), and as one goes off the top, re-use it at the bottom, changing its properties rather than creating a whole new view.
The above is complicated logic, though, and why reinvent the wheel? The List View control with a custom adapter should be more than capable of rendering the data like you're attempting to do, and the hard work has already been done.