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 );