{"id":592,"date":"2020-06-29T13:18:42","date_gmt":"2020-06-29T05:18:42","guid":{"rendered":"https:\/\/badgameshow.com\/fly\/?p=592"},"modified":"2020-06-29T13:19:10","modified_gmt":"2020-06-29T05:19:10","slug":"android-swiperefreshlayout%e4%b8%8b%e6%8b%89%e5%88%b7%e6%96%b0%e6%95%b8%e6%93%9a","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/fly\/android-swiperefreshlayout%e4%b8%8b%e6%8b%89%e5%88%b7%e6%96%b0%e6%95%b8%e6%93%9a\/","title":{"rendered":"Android SwipeRefreshLayout(\u4e0b\u62c9\u5237\u65b0\u6578\u64da)"},"content":{"rendered":"<h3>1.\u5148\u5c0e\u5165\u51fd\u793a\u5eab(build.gradle: Module)<\/h3>\n<pre><code class=\"language-Gradle line-numbers\">dependencies {\n   implementation \"androidx.swiperefreshlayout:swiperefreshlayout:1.1.0\"\n}\n<\/code><\/pre>\n<h3>2.\u7a0b\u5f0f\u78bc\u7bc4\u4f8b<\/h3>\n<h4>a.layout<\/h4>\n<pre><code class=\"language-XML line-numbers\">&lt;androidx.swiperefreshlayout.widget.SwipeRefreshLayout\n     android:id=\"@+id\/swipe\"\n     android:layout_width=\"match_parent\"\n     android:layout_height=\"match_parent\"&gt;\n\n     &lt;androidx.recyclerview.widget.RecyclerView\n         android:id=\"@+id\/recycler\"\n         android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\" \/&gt;\n\n&lt;\/androidx.swiperefreshlayout.widget.SwipeRefreshLayout&gt;\n<\/code><\/pre>\n<h4>b.\u5275\u5efa\u5c0d\u8a71\u6846<\/h4>\n<pre><code class=\"language-Kotlin line-numbers\">     \/\/\u8a2d\u5b9a\u5237\u65b0View\u7684\u984f\u8272\n     swipe.setColorSchemeResources(\n         R.color.colorPrimary,\n         R.color.colorPrimaryDark,\n         R.color.colorAccent\n     )\n\n     \/\/\u5237\u65b0\u76e3\u807d\n     swipe.setOnRefreshListener {\n         \/\/3\u79d2\u5f8c \u5237\u65b0\u6548\u679c\u6d88\u5931\n         object :CountDownTimer(3000,1000) {\n             override fun onFinish() {\n                 swipe.isRefreshing = false\n             }\n\n             override fun onTick(p0: Long) {\n\n             }\n         }.start()\n     }\n<\/code><\/pre>\n<h3>4.\u6548\u679c\u5c55\u793a<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/06\/SwipeRefreshLayout.gif\" alt=\"\" \/><\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>1.\u5148\u5c0e\u5165\u51fd\u793a\u5eab(build.gradle: Module) dependencies { implement &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[5],"tags":[13,15,93],"class_list":["post-592","post","type-post","status-publish","format-standard","hentry","category-android","tag-android","tag-kotlin","tag-swiperefreshlayout"],"_links":{"self":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/comments?post=592"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/592\/revisions"}],"predecessor-version":[{"id":594,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/592\/revisions\/594"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/media?parent=592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/categories?post=592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/tags?post=592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}