{"id":10044,"date":"2014-04-09T18:36:00","date_gmt":"2014-04-10T01:36:00","guid":{"rendered":"http:\/\/blog.xamarin.com\/?p=10044"},"modified":"2014-04-09T18:36:00","modified_gmt":"2014-04-10T01:36:00","slug":"swipe-to-refresh-added-to-android-support-v4-component","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/swipe-to-refresh-added-to-android-support-v4-component\/","title":{"rendered":"Swipe To Refresh added to Android"},"content":{"rendered":"<p>\t\t\t\t<img decoding=\"async\" src=\"\/wp-content\/uploads\/sites\/44\/2019\/04\/swipe-refresh-animation.gif\" alt=\"Swipe-to-Refresh animation\" width=\"173\" height=\"308\" class=\"alignright size-full wp-image-10258\" \/><\/p>\n<p>Google recently released an update to the Android support library bringing in an exciting new standard implementation of a pattern that they have been progressively introducing through applications such as GMail or Google Now.<\/p>\n<p>This pattern, called swipe-to-refresh, uses an upward pull user feedback to inform the app that a data refresh is requested. This complete another common pattern, infinite scrolling, that instead use a downward movement to load more data.<\/p>\n<p>We have updated <a href=\"http:\/\/components.xamarin.com\/view\/xamandroidsupportv4-18\">our component<\/a> to expose the new <code>SwipeRefreshLayout<\/code> class that implements the pattern. To make use of it, simply wrap in your existing Xamarin.Android app layout.<\/p>\n<pre class=\"lang:xml decode:true\">\n&lt;android.support.v4.widget.SwipeRefreshLayout\n    android:id=&quot;@+id\/refresher&quot;\n    android:layout_width=&quot;match_parent&quot;\n    android:layout_height=&quot;match_parent&quot;&gt;\n    &lt;FrameLayout\n        android:id=&quot;@+id\/container&quot;\n        android:layout_width=&quot;match_parent&quot;\n        android:layout_height=&quot;match_parent&quot; \/&gt;\n&lt;\/android.support.v4.widget.SwipeRefreshLayout&gt;\n<\/pre>\n<p>Setting up the <code>SwipeRefreshLayout<\/code> instance is pretty easy from code. You simply have to define a color scheme and a callback that is invoked when an update operation is requested by the user.<\/p>\n<pre class=\"lang:csharp decode:true\">\nrefresher = FindViewById&lt;SwipeRefreshLayout&gt; (Resource.Id.refresher);\nrefresher.SetColorScheme (Resource.Color.xam_dark_blue,\n                          Resource.Color.xam_purple,\n                          Resource.Color.xam_gray,\n                          Resource.Color.xam_green);\nrefresher.Refresh += async delegate {\n\tawait forum.FetchItems (clear: true);\n\trefresher.Refreshing = false;\n};\n<\/pre>\n<p>The color scheme can be any set of color or the same color. In any case, the first parameter is also used as the initial feedback bar background.<\/p>\n<p>We have also added <a href=\"http:\/\/docs.xamarin.com\/samples\/SwipeToRefresh\/\">a dedicated sample<\/a> that shows how this code can be integrated in a complete scenario, including a complex layout utilizing fragments.\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google recently released an update to the Android support library bringing in an exciting new standard implementation of a pattern that they have been progressively introducing through applications such as GMail or Google Now. This pattern, called swipe-to-refresh, uses an upward pull user feedback to inform the app that a data refresh is requested. This [&hellip;]<\/p>\n","protected":false},"author":1925,"featured_media":39167,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[5,4],"class_list":["post-10044","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","tag-android","tag-xamarin-platform"],"acf":[],"blog_post_summary":"<p>Google recently released an update to the Android support library bringing in an exciting new standard implementation of a pattern that they have been progressively introducing through applications such as GMail or Google Now. This pattern, called swipe-to-refresh, uses an upward pull user feedback to inform the app that a data refresh is requested. This [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/10044","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/users\/1925"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=10044"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/10044\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media\/39167"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=10044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=10044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=10044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}