Simple use of Android Spinner

Source: Internet
Author: User
 

1. store data in array. xml

The content of array. XML is as follows:

<String-array name = "newhouse_check_zone"> <item> none </item> <item> all </item> <item> sets </item> <item> total area </ item> <item> total amount </item> </string-array>

2. InProgramTo call the spzone is my spinner control, and the layout of the drop-down list is the default layout of a drop-down list of Android. I set the string zone to null when "NONE" is displayed.

Spzone. setadapter (arrayadapter. createfromresource (this, R. array. newhouse_check_zone, android. r. layout. simple_spinner_dropdown_item); spzone. setonitemselectedlistener (New onitemselectedlistener () {@ overridepublic void onitemselected (adapterview <?> Arg0, view arg1, int arg2, long arg3) {zone = spzone. getselecteditem (). tostring (); If (zone. equals ("NONE") {zone = NULL ;}@ overridepublic void onnothingselected (adapterview <?> Arg0) {zone = NULL ;}});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.