One of the great ideas formalized in the new Material Design user interface guidelines is the Swipe to Refresh UI pattern. It’s found its way into many popular Android apps like Facebook, Google Newsstand, Trello, Gmail and many others.
Here’s what it looks like: The Swipe to Refresh pattern is a nice fit for adapter-backed views (Recycler View and List View, for example) that also need to support user-requested refreshes, like a list that displays a Twitter newsfeed that’s updated by a user, on demand.
We attach adapter consisting of either Fragment objects or simple View objects.
Note: You can download source code of a sample application from here to run the android application. It keeps maximum three views in memory, one which is currently visible, one which is left and one is right of the visible item.
Anyway, the problem isn't that it can't be done 'manually' - but rather that there are a myriad of ways that you can hook up custom link/command processing and they are all similar but yet quite different.
None of them feels natural to me, so quite frequently - especially if I haven't written that code in a while - I spent way more time than I should rediscovering what approach I should use the hard way.
Here's some code that needs to retrieve a Pk of one of the bound items and then perform some work on the data (in this case the business object): This seems like a lot of code to have to write just to retrieve data context.
The code first has to retrieve the Grid View Row, which is done by retrieving the Command Argument which in this case a row index of the rendered grid view items.
In Code Behind you have to do a bit of work though if you want to retrieve the proper context from a Data Item.The first thing we need to do is add the support library to our application’s .We’re going to add a List View and a Swipe Refresh Layout widget to the layout file.The List View will display content we want to update using the Swipe to Refresh pattern, and the Swipe Refresh Layout widget will provide the basic functionality.Notice that List View is nested within the Swipe Refresh Layout.
In simplest implementation, we return View or Fragment created in instantiate Item(View Group, int) itself and in is View From Object(View, Object) method we simply compare View and Object to check the association between them.