Android ListViews Reinvented

I learned something new last week that I felt I probably should have learned a long time ago.  As I know from my previous experience in Android development, ListViews only scroll vertically.  In the past, there was no out of the box support for horizontal ListViews in Android.  Developers had to create them manually or use 3rd party libraries hosted on GitHub.  If you examined a 3rd parties source code, you would see implementing a horizontal ListView is not an easy task.  With the release of Android 4.4 KitKat (API Level 19), a new control was added to the Android SDK.  This new control is called a RecyclerView, and is available via the Android Support Library v7.


Luckily for us Xamarin Developers, we have out of the box binding to this library, so we can use this just like native Java developers.  In this post I’m going to show you how to implement a vertical ListView (just like a standard ListView), as well as a Horizontal ListView.  But we are not going to use the old legacy ListView control or a 3rd party library.  We are going to use the now out of the box RecyclerView to implement both.  The good news is that the since this is available in the Android Support Library v7, this control can run on devices from the current version of Android, all the way down to API Level 7 (Android 2.1 Eclair).  So this control remains backwards compatible with almost any device out there.  So let’s get coding!