Use spinner and setdropdownviewresource
Exercise 2: jointly use the spinner and setdropdownviewresource
Setdropdownviewresource of the adapter allows you to set the display mode of the drop-down menu, define the XML in the Res/layout directory, and set textview in the drop-down menu, for exampleProgramIn "R. layout. myspinner_dropdown" is the custom drop-down menu textview style. In addition to changing the drop-down menu style, you also made some dynamic effects on the spinner. When you click the spinner, after shaking the spinner, the drop-down menu (myanimation) will appear again ).
Step 2: Write the layout file main. xml and insert a button and a textview on the interface;
Step 2: Write color. XML to set the UI color;
Step 2: Create an anim folder under the res directory to store the animation effect and create a new my_anim.xml file;
Step 2: Create a New myspinner_dropdown.xml file in the layout folder under the res directory to store the layout of the pop-up content in the drop-down menu;
Step 2: Compile the event processing file Lianhe. java. The specific implementation process is as follows:
(1) define a drop-down menu to get the object with findviewbyid.
(2) define a string array and an arrayadepter to display the country to be selected.
(3) set a style for the drop-down menu.
(4) set the content adapter for the drop-down menu.
(5) add an animation to the drop-down menu.
Main Implementation of file Lianhe. JavaCodeAs follows:
The effect after the program is executed is 6-4. When you click the drop-down list box, a floating option box is displayed. You can select a country option, as shown in Figure 6-5.
This article is from the book Android .
Book details: http://blog.csdn.net/broadview2006/article/details/7104054