I have a question about how to improve the performance of a large horizontal linear layout.
I am creating a table like view that can have anywhere from 50 to 2,500 entries. Each entry is a LinearLayout containing a TextView with some simple text. I have implemented the design by utilizing the LinearListView library. This library allows an ListAdapter to be bound to a LinearLayout to display a view in a horizontal or vertical orientation.
The way I have implemented this currently is by utilizing two of these LinearListViews. One is vertical who data consists of horizontal LinearListViews. This gives the desired output by creating a table view. I then wrap the table within a Horizontal ScrollView with a Verticle ScrollView so that the table can be panned (scrolled in either up/down or left/right).
The issue with this layout is that the adapters getView() is called only at the initialization of the views (the first time it inflates the first linearList it inflates every view). Once each view is inflated, the getView() method is never called again while scrolling through the list (it scrolls very well of course as it is all loaded). The total amount of time it takes to inflate is not as big of deal, but the fact that it inflates every item in the table in a row locks up the main UI thread. I need the view to "lazy load" each item in the table without blocking the UI thread.
I have a screen shot, but I do not have enough reputation to post it nor do I have enough to use two links. I will attempt to put a external photo link in the comments. (In reference to the screenshot) The table data is generated in a group of async tasks where each table item is the current time in Milliseconds (I am aware that the table rows are not ordered due to the async nature and will fix that later). This actual app serves no purpose other than to demonstrate this library.
I added the "Change Data Randomly" button which will create a random point (int x,int y) and generate a random string and replace the cell at (x,y) with that string. This happens almost instantly by calling that particulars adapter's getView() method. So access to this table is very quick! Again, it is the initial inflating that is locking the main UI thread.
A few important notes to summarize:
- The UI needs to be in a table format where each row could have different lengths and can dynamically be changed. Items can be removed and added from any part.
- My getView() methods (2 adapters & 2 LinearListViews) are utilizing the ViewHolder pattern and are fairly optimized.
- My main goal is not to necessarily improve the total speed, but to efficiently load each view so that the main UI thread is not locked up (I want to still be able to use the interface while the table loads).
- Consider the content of each cell to be a textview for simplicity (Images and other complex components can be supported later).
- The table needs to be able to scroll in any direction (it is not possible to display all of its contents on the screen at one time).
I have found this application (TV SideView) which creates a fairly large table view that loads really nicely. I ultimately would want to achieve something similar to this (look at the "Program Guide" page to see the actual table). It loads a bunch of cells and you can still use the UI (drag the table around when it first opens and you will see the cells loading).
I will keep chugging away at this and post back anything new I find.
Any advice and help would be greatly appreciated! Thank you so much for your time!
-Evan