{"id":4849,"date":"2019-06-07T13:04:19","date_gmt":"2019-06-07T07:34:19","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=4849"},"modified":"2019-06-07T13:04:34","modified_gmt":"2019-06-07T07:34:34","slug":"how-to-use-checkbox-and-radio-buttons","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-use-checkbox-and-radio-buttons\/","title":{"rendered":"How to use checkbox and radio buttons"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">How to use checkbox and radio buttons<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Date : 05\/06\/2019<\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">step 1 : check box <\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Check boxes allow the user to select one or more options from a set. Typically, you should present each checkbox option in a vertical list.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"236\" height=\"69\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-04-19.png\" alt=\"\" class=\"wp-image-4853\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The implementation part is simple that you need to mention check-box in your XML file. You can set <code>onclick<\/code> attribute to the boxes. Make sure that the method you mentioned are public , void, View as the only parameter. The one of the check boxes mentioned above is here.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img fetchpriority=\"high\" decoding=\"async\" width=\"528\" height=\"128\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-02-59.png\" alt=\"\" class=\"wp-image-4852\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-02-59.png 528w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-02-59-300x73.png 300w\" sizes=\"(max-width: 528px) 100vw, 528px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">On user click events, we can do something we want by setting up a listener.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"793\" height=\"182\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-11-39.png\" alt=\"\" class=\"wp-image-4854\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-11-39.png 793w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-11-39-300x69.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-11-39-768x176.png 768w\" sizes=\"(max-width: 793px) 100vw, 793px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Step 2 : radio button<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Radio buttons allow the user to select one option from a set. You should use radio buttons for optional sets that are mutually exclusive if you think that the user needs to see all available options side-by-side. If it&#8217;s not necessary to show all options side-by-side, use a&nbsp;spinner&nbsp;instead. It will look like this.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"188\" height=\"28\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-22-33.png\" alt=\"\" class=\"wp-image-4856\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Option can be set to horizontal or vertical in the <code>RadioGroup<\/code>.  We have to set the radio buttons inside a <code>RadioGroup<\/code>. And can set one of the button by default as clicked.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"510\" height=\"411\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-20-12.png\" alt=\"\" class=\"wp-image-4855\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-20-12.png 510w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-20-12-300x242.png 300w\" sizes=\"(max-width: 510px) 100vw, 510px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Every feature in android have feature to respond upon user actions. So we can find which button being clicked by invoking <code>isChecked()<\/code> method on the button.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also setup  listener to absorb at run-time.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"706\" height=\"147\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-21-33.png\" alt=\"\" class=\"wp-image-4857\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-21-33.png 706w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/06\/Screenshot-from-2019-06-06-09-21-33-300x62.png 300w\" sizes=\"(max-width: 706px) 100vw, 706px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you using pheonixsolutions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you find it useful, share it to keep alive.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to use checkbox and radio buttons Date : 05\/06\/2019 step 1 : check box Check boxes allow the user [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1021],"tags":[569,678,679],"class_list":["post-4849","post","type-post","status-publish","format-standard","hentry","category-mobile-flutter","tag-android","tag-checkbox","tag-radiobutton","psol-cat-mobile-flutter"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1gd","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=4849"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4849\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}