
{"id":832,"date":"2016-11-24T11:54:29","date_gmt":"2016-11-24T03:54:29","guid":{"rendered":"http:\/\/www.jiandaima.com\/blog\/?p=832"},"modified":"2016-11-24T11:54:29","modified_gmt":"2016-11-24T03:54:29","slug":"%e5%ae%89%e5%8d%93%e4%b8%89%e7%8a%b6%e6%80%81%e5%88%87%e6%8d%a2%e6%8c%89%e9%92%ae%e6%ba%90%e7%a0%81%e4%b8%8b%e8%bd%bd-tristate-toggle-button%e7%a4%ba%e4%be%8b%e6%ba%90%e7%a0%81%e4%b8%8b%e8%bd%bd","status":"publish","type":"post","link":"http:\/\/www.jiandaima.com\/blog\/archives\/832.html","title":{"rendered":"\u5b89\u5353\u4e09\u72b6\u6001\u5207\u6362\u6309\u94ae\u6e90\u7801\u4e0b\u8f7d TriState Toggle Button\u793a\u4f8b\u6e90\u7801\u4e0b\u8f7d"},"content":{"rendered":"<p>\u5b89\u5353\u4e09\u72b6\u6001\u5207\u6362\u6309\u94ae\u6e90\u7801\u4e0b\u8f7d TriState Toggle Button\u793a\u4f8b\u6e90\u7801\u4e0b\u8f7d<\/p>\n<p>\u4e00\u4e2a\u5b8c\u5168\u53ef\u5b9a\u5236\u548c\u8d85\u7b80\u5355\u7684\u4e09\u6001\u5207\u6362\u6309\u94ae\uff08\u5982\u679c\u4f60\u559c\u6b22\u5207\u6362\u6309\u94ae\uff09\u4e3aAndroid\uff0c\u57fa\u4e8eiOS\u7684\u5916\u89c2\u548c\u611f\u89c9\u3002 \u53ef\u4ee5\u4e0e\u4e09\u4e2a\u72ec\u7acb\u7684\u72b6\u6001\uff0c\u6216\u4e0e\u4e24\u4e2a\u72b6\u6001\u50cf\u4e00\u4e2a\u6807\u51c6\u7684\u590d\u9009\u6846\uff0c\u6216\u4e24\u4e2a\u72b6\u6001\u52a0\u4e00\u4e2a\u672a\u5b9a\u4e49\u3002<\/p>\n<p>\u4ecb\u7ecd\uff1a<\/p>\n<p>\u5f00\u7bb1\u5373\u7528\u7684\u4e09\u6001\u5207\u6362<br \/>\n\u5b8c\u5168\u53ef\u5b9a\u5236\u548c\u6b3e\u5f0f<br \/>\n\u53ef\u4ee5\u6210\u4e3a\u4e00\u4e2a\u7ecf\u5178\u76842\u72b6\u6001\u5207\u6362\u8fd4\u56de\u5e03\u5c14<br \/>\n\u53ef\u4ee5\u6210\u4e3a\u4e00\u4e2a2.5\u72b6\u6001\u5207\u6362\uff1a\u5f00\/\u5173\u548c\u4e0d\u53ef\u9009\u62e9\u7684\u4e2d\u95f4\u6309\u94ae<br \/>\n\u53ef\u4ee5\u542f\u7528\/\u7981\u7528<br \/>\n\u53ef\u4ee5\u901a\u8fc7\u7f16\u7a0b\u63a7\u5236<\/p>\n<p><a href=\"https:\/\/github.com\/BeppiMenozzi\/TriStateToggleButton\/raw\/master\/images\/tstb.gif\" class=\"highslide-image\" onclick=\"return hs.expand(this);\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/github.com\/BeppiMenozzi\/TriStateToggleButton\/raw\/master\/images\/tstb.gif\" width=\"380\" height=\"608\" alt=\"\u5b89\u5353\u4e09\u72b6\u6001\u5207\u6362\u6309\u94ae\u6e90\u7801\u4e0b\u8f7d TriState Toggle Button\u793a\u4f8b\u6e90\u7801\u4e0b\u8f7d\" class=\"aligncenter size-medium\" \/><\/a><\/p>\n<p>\u4f7f\u7528\u65b9\u6cd5\uff1a<br \/>\n\u5b89\u88c5 (Gradle)<\/p>\n<p>\u5728\u4f60\u7684\u9879\u76ee build.gradle \u6587\u4ef6\u4e2d:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nallprojects {\r\n    repositories {\r\n        ...\r\n        maven { url &quot;https:\/\/jitpack.io&quot; }\r\n        ...\r\n    }\r\n}\r\n<\/pre>\n<p>In your Application's or Module's build.gradle file:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\ndependencies {\r\n    ...\r\n    compile 'com.github.BeppiMenozzi:TriStateToggleButton:1.0.4'\r\n    ...\r\n}\r\n<\/pre>\n<p>\u6700\u5c0f\u4f7f\u7528\uff1a<\/p>\n<p>Layout:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n...\r\nxmlns:app=&quot;http:\/\/schemas.android.com\/apk\/res-auto&quot;\r\n...\r\n&lt;it.beppi.tristatetogglebutton_library.TriStateToggleButton\r\n        android:layout_width=&quot;80dp&quot;\r\n        android:layout_height=&quot;40dp&quot;\r\n        android:id=&quot;@+id\/tstb_1&quot;\r\n \/&gt;\r\n<\/pre>\n<p>\u76d1\u542c\uff1a<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n...\r\nTriStateToggleButton tstb_1 = (TriStateToggleButton) findViewById(R.id.tstb_1);\r\ntstb_1.setOnToggleChanged(new TriStateToggleButton.OnToggleChanged() {\r\n        @Override\r\n        public void onToggle(TriStateToggleButton.ToggleStatus toggleStatus, boolean booleanToggleStatus, int toggleIntValue) {\r\n            switch (toggleStatus) {\r\n                case off: break;\r\n                case mid: break;\r\n                case on: break;\r\n            }\r\n        }\r\n    });\r\n...\r\n<\/pre>\n<p>\u5728onToggle\uff08\uff09\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528ToggleStatus\u7c7b\u578b\u503c\uff0c\u6216\u8005\u9650\u5236\u81ea\u5df1\u4f7f\u7528\u5e03\u5c14\u503c\u6216\u6574\u6570\uff080\uff0c1\uff0c2\uff09\uff0c\u5982\u679c\u4f60\u60f3\u8981\u5b83\u5bb9\u6613\u3002<\/p>\n<p>\u8981\u62e5\u6709\u53cc\u72b6\u6001\u5207\u6362\u6309\u94ae\uff1a<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n &lt;it.beppi.tristatetogglebutton_library.TriStateToggleButton\r\n        android:layout_width=&quot;80dp&quot;\r\n        android:layout_height=&quot;40dp&quot;\r\n        android:id=&quot;@+id\/tstb_1&quot;\r\n        app:tbIsMidSelectable=&quot;false&quot;\r\n \/&gt;\r\n<\/pre>\n<p>\u8981\u5177\u6709\u53cc\u72b6\u6001\u5207\u6362\u6309\u94ae\uff0c\u5177\u6709\u672a\u5b9a\u4e49\u7684\u8d77\u59cb\u503c\uff1a<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n &lt;it.beppi.tristatetogglebutton_library.TriStateToggleButton\r\n        android:layout_width=&quot;80dp&quot;\r\n        android:layout_height=&quot;40dp&quot;\r\n        android:id=&quot;@+id\/tstb_1&quot;\r\n        app:tbIsMidSelectable=&quot;false&quot;\r\n        app:tbDefaultStatus=&quot;mid&quot;\r\n \/&gt;\r\n<\/pre>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u5b89\u5353\u4e09\u72b6\u6001\u5207\u6362\u6309\u94ae\u6e90\u7801\u4e0b\u8f7d TriState Toggle Button\u793a\u4f8b\u6e90\u7801\u4e0b\u8f7d\u3002\u4e00\u4e2a\u5b8c\u5168\u53ef\u5b9a\u5236\u548c\u8d85\u7b80\u5355\u7684\u4e09\u6001\u5207\u6362\u6309\u94ae\uff08\u5982\u679c\u4f60\u559c\u6b22\u5207\u6362\u6309\u94ae\uff09\u4e3aAndroid\uff0c\u57fa\u4e8eiOS\u7684\u5916\u89c2\u548c\u611f\u89c9\u3002 \u53ef\u4ee5\u4e0e\u4e09\u4e2a\u72ec\u7acb\u7684\u72b6\u6001\uff0c\u6216\u4e0e\u4e24\u4e2a\u72b6\u6001\u50cf\u4e00\u4e2a\u6807\u51c6\u7684\u590d\u9009\u6846\uff0c\u6216\u4e24\u4e2a\u72b6\u6001\u52a0\u4e00\u4e2a\u672a\u5b9a\u4e49\u3002<\/p>\n","protected":false},"author":1,"featured_media":522,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[255,256],"class_list":["post-832","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-application-source-code","tag-255","tag-256"],"post_thumbnail_image":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/05\/64022-3.png?imageView2\/1\/w\/300\/h\/300#","content_first_image":"https:\/\/github.com\/BeppiMenozzi\/TriStateToggleButton\/raw\/master\/images\/tstb.gif","post_medium_image_300":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/05\/64022-3.png?imageView2\/1\/w\/600\/h\/356#","post_thumbnail_image_624":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/05\/64022-3.png","post_frist_image":"https:\/\/github.com\/BeppiMenozzi\/TriStateToggleButton\/raw\/master\/images\/tstb.gif","post_medium_image":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/05\/64022-3.png?imageView2\/1\/w\/600\/h\/356#","post_large_image":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/05\/64022-3.png","post_full_image":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/05\/64022-3.png","post_all_images":[{"imagesurl":"https:\/\/github.com\/BeppiMenozzi\/TriStateToggleButton\/raw\/master\/images\/tstb.gif","id":"image0"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":5,"total_comments":0,"category_name":"\u5e94\u7528\u7a0b\u5e8f\u6e90\u7801","post_date":"2016-11-24","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2020\/02\/img_5e44112722964.png","avatarurls":[],"related_posts":[],"pageviews":786,"next_post_id":874,"next_post_title":"\u6e05\u6670\u7075\u6d3b\u7b80\u5355\u6613\u7528\u7684\u5b89\u5353\u5e94\u7528\u66f4\u65b0\u5e93\u6e90\u7801\u4e0b\u8f7d","previous_post_id":822,"previous_post_title":"iOS \u65e5\u5386\u63a7\u4ef6 RCalendarPicker  \u65e5\u5386\u63a7\u4ef6\u6e90\u7801 \u65e5\u5386\u9009\u62e9\u63a7\u4ef6\u6e90\u7801\uff0c\u65e5\u5386\uff0c\u65e5\u671f\u9009\u62e9\u6e90\u7801","_links":{"self":[{"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/posts\/832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/comments?post=832"}],"version-history":[{"count":0,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/posts\/832\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/media\/522"}],"wp:attachment":[{"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/media?parent=832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/categories?post=832"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/tags?post=832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}