Use of the Spinner control in Android Development

Source: Internet
Author: User

Use of the Spinner control in Android Development

In Android mobile app development, the following five common methods are used for the Spinner object.

Usage 1: displays the Spinner option statically as a resource

Usage 2: dynamically display the Spinner option in code mode

Usage3: Displays both images and text

Usage 4: hybrid mode

Here I am just a simple way to learn how to use 1 and 3. For other methods, refer to the following blog and write well.

Http://www.cnblogs.com/freeliver54/archive/2012/09/03/2668363.html

The preceding Declaration variables and initialization will not be repeated. Let's learn how to use it directly.

Note: In the resource value folder, store the string selection information in the drop-down box in the xml file.

<String name = "spin_prompt"> select the expenditure type </string> <string-array name = "outAccount"> <item> utilities </item> <item> rent </ item> <item> taxi fare </item> <item> meal fee </item> <item> other fees </item> </string-array>

If there is a return button, you can add it to the event of the return button as follows:

// Set the category drop-down list. By default, select the first item (the string information in the drop-down box is stored in addinaccount. xml). spInType. setSelection (0 );

 

Related Article

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.