{"id":477,"date":"2015-01-09T18:12:31","date_gmt":"2015-01-10T02:12:31","guid":{"rendered":"http:\/\/appinventor.pevest.com\/?p=477"},"modified":"2015-01-09T18:12:31","modified_gmt":"2015-01-10T02:12:31","slug":"using-the-spinner-control-for-selecting-items","status":"publish","type":"post","link":"https:\/\/coldstreams.com\/appinventor\/2015\/01\/09\/using-the-spinner-control-for-selecting-items\/","title":{"rendered":"Using the Spinner Control for Selecting Items"},"content":{"rendered":"<p>When your app needs the user to select an\u00a0item from a list of choices, use the <em>Spinner<\/em> control.<\/p>\n<p>Suppose we have a really simple restaurant menu that provides a choice of tacos and drinks. Our customer may select a Chicken, Beef or Vegan taco from an interface that looks like this:<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2014\/12\/Spinner-Screen.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-480\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2014\/12\/Spinner-Screen-576x1024.png\" alt=\"Spinner-Screen\" width=\"272\" height=\"484\" \/><\/a><\/p>\n<p>Touching the Chicken Taco item on the screen displays a set of options &#8211; select a\u00a0desired item from\u00a0the list:<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/01\/SpinnerScreenshot.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-503\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/01\/SpinnerScreenshot-576x1024.png\" alt=\"SpinnerScreenshot\" width=\"266\" height=\"472\" \/><\/a><strong>The Designer View<\/strong><\/p>\n<p><!--more--><\/p>\n<p>The item labeled &#8220;add items&#8230;&#8221; is a Spinner control, dragged out of the Palette. There are two Spinner controls in this user interface:<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/01\/SpinnerMain.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-505\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/01\/SpinnerMain.png\" alt=\"SpinnerMain\" width=\"274\" height=\"375\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Select the first <em>Spinner<\/em> control and then go to the Properties for that control. In the <em>ElementsFromString<\/em> item, enter <em>Chicken taco, beef taco, vegan taco<\/em>. These items, separated by commas, become the elements of the <em>Spinner<\/em> list.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/01\/Spinner1Properties.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-507 size-full\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/01\/Spinner1Properties.png\" alt=\"Spinner1Properties\" width=\"154\" height=\"185\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Do the same for the drinks on the menu:<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/01\/Spinner2Properties.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-508 size-full\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/01\/Spinner2Properties.png\" alt=\"Spinner2Properties\" width=\"159\" height=\"186\" \/><\/a><\/p>\n<p><strong>Blocks\u00a0Code<\/strong><\/p>\n<p>The code is so simple it hardly needs an explanation! \u00a0When the user selects an item, the <em>AfterSelecting<\/em> event occurs. The selected item is obtained from the local variable <em>selection<\/em>:<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/01\/SpinnerBlocks.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-506 aligncenter\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/01\/SpinnerBlocks.png\" alt=\"SpinnerBlocks\" width=\"474\" height=\"230\" \/><\/a><\/p>\n<p><strong>Key Features Shown<\/strong><\/p>\n<ul>\n<li>Spinner controls are used to select from a list of items<\/li>\n<li>Add a spinner control in the Designer and set an initial list of items in Properties<\/li>\n<li>Obtain the selected item with an event handler for the Spinner&#8217;s <em>AfterSelecting<\/em> event.<\/li>\n<\/ul>\n<p><strong>Please Share on Social Media<\/strong><\/p>\n<p>Please click on the buttons below this post to share with your friends on Facebook or other social media.<\/p>\n<p>If you are not already following this blog, click on the following links to like on Facebook, add to your Google+ circles or follow on Twitter or in your RSS news reader. Thank you for visiting!<\/p>\n<p><a href=\"https:\/\/www.facebook.com\/appinventor2\"><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2014\/10\/facebook-like.png\" alt=\"\" width=\"150\" \/><\/a><a href=\"https:\/\/plus.google.com\/107302082825289724871\/posts\"><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/coldstreams.com\/images\/plus-badge.png\" alt=\"\" width=\"48\" \/><\/a><a href=\"http:\/\/twitter.com\/appinventorplus\"><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/coldstreams.com\/images\/twitter-follow.png\" alt=\"\" width=\"100\" \/><\/a><a href=\"http:\/\/appinventor.pevest.com\/?feed=rss2\"><img decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/coldstreams.com\/images\/rss.png\" alt=\"\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When your app needs the user to select an\u00a0item from a list of choices, use the Spinner control. Suppose we have a really simple restaurant menu that provides a choice of tacos and drinks. Our customer may select a Chicken, Beef or Vegan taco from an interface that looks like this: Touching the Chicken Taco &hellip; <a href=\"https:\/\/coldstreams.com\/appinventor\/2015\/01\/09\/using-the-spinner-control-for-selecting-items\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Using the Spinner Control for Selecting Items<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-477","post","type-post","status-publish","format-standard","hentry","category-components"],"_links":{"self":[{"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/posts\/477","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/comments?post=477"}],"version-history":[{"count":0,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/posts\/477\/revisions"}],"wp:attachment":[{"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/media?parent=477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/categories?post=477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/tags?post=477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}