I was very excited to see that the latest version of Support v4 for Android was updated to include as most people would says it a “Pull to Refresh”… or as Google would call it a “SwipeRefreshLayout”. It is now available in the Xamarin.Android Support v4 Component so we should probably take advantage of it! This is actually a really slick Layout that you can make the parent of any 1 layout and when the user swipes down on it you will get notified that you are supposed to refresh the content. This means you can now get rid of all of your refresh icon buttons in your UI and follow the same patterns Google has for their apps that your users will be used to.
Naturally I wanted to implement an MvvmCross version of this since I did an MvvmCross binding for UIRefreshControl on iOS a while back. So the goals here are simple:
- Execute an ICommand when someone pulls down to refresh
- Bind a bool to begin and end the refreshing spinner
So I created a very very simple MvxSwipeRefreshLayout which you can find the Gist for RIGHT HERE! In addition you will just need to implement a bit of code in your .axml layout and in your code behind to set the Refresh command.