I have an Android game that includes a screen that lists all ongoing games, short description, opponents name and profile picture etc. Pretty similar to what Zynga’s With Friends games have. However, I’ve always had huge performance issues with rendering the list of games when you have tens of ongoing games which all have to be listed.
Since the loading times can be 5+ seconds, I figured it’s time to do some profiling and figure out the bottlenecks. It turns out that roughly 70% of the time goes to inflating and initializing the layout elements (which have been minimized to be as flat and light as possible), so even if I could optimize the rest of the code to happen instantly, the loading time would still be unacceptable from UX perspective.
A simple ListView wouldn’t work due to the additional UI elements, such as buttons etc that do not follow the same template as the games. On iOS a similar structure is rendered almost instantly, even on 3GS, so I’d expect at least similar speeds from a similarly powered Android devices. What are my options to reduce the time used for layout inflation and initialization?
(A Words With Friends screenshot for reference if you don’t know what it looks like)
You should look at this conference about
ListView. It teach how to implement it on a good way, doing as a minimum of allocation as possible. The content that could interest you begins at the 9th minute.convetViewprovided by thegetViewfunctionViewHolderto improve the access speedAnother thing, you should try to manage your image loading to be sure that part is not blocking the rendering for a while.
There is a good tool to profile your application, to know what are the laggy functions in your code : look at that here