The spinner style that comes with the Android system is far from satisfying the spinner UI style requirements in our actual development process, so we definitely need to modify our spinner style to suit the style of the application. The system gives us two kinds of common modification methods, one is to use the XML static, the other is the Java code dynamic to mo
Drop-down menu Spinner simple Pure string versionpublic class Mainactivity extends Activity implements adapterview.onitemselectedlistener{private Spinner Spinner; private TextView text; Private list Drop-down menu Spinner simple Pure string version
Disclaimer: The book "Secrets of Android Application Development", which records the logs of the book, references the relevant code and summary, and has no commercial use, it is completely a record of self-learning, and many problems will inevitably occur in learning just now. If there are any mistakes, please criticize them a lot.
1. Multiple options (checkbox)
Multiple-choice is similar to single-choice. You need to monitor each control.
Ii. drop-down list (
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
(1) Two methods to extract the data source in the spinner: Through the list collection, or through the XML file configuration(2) Layout code such as the following:(2)Package Com.example.spinners;import Java.util.arraylist;import Java.util.list;import android.app.activity;import Android.os.bundle;import Android.view.menu;import Android.view.view;import Android.widget.adapterview;import Android.widget.adapterview.onitemselectedlistener;import Android.wi
Android drop-down menu, such as
Steps:
1. Define spinner control
Copy Code code as follows:
Android:id= "@+id/spinner"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:prompt= "@string/planet_prompt"/>
2. Create a new Android XML file named arrays under the Res/values/folder
Copy Code code as follows:
planets" >
The con
The key section code is as follows1, SpinnnerIn the layout file: To define an object:Private Spinner mspinnerselectleavetype;//Select leave typeTo bind listener events after acquiring an object:Mspinnerselectleavetype.setonitemselectedlistener (New Onitemselectedlistener () {@Overridepublic void Onitemselected (adapterviewThe key code for binding data to Spinnner is as follows:/*** Spinner binding data for
:Custom spinner actually consists of two parts:The first part is used to open the drop-down list of buttons, this green background directly set spinner background on the line, the material file as follows:Note that the text in the spinner control does not directly modify the text interface, the text is actually set in the adapter, for example:arrayadapterr.layout
Loading animations are required for the project, because the Ionic framework is used, and the Ionspinner in the framework provides many animated icons for rotating loads. When your interface loads, you can present the appropriate load icon to the user. Choose a suitable one based on your project needs, and here are some of the effects of loading animations:650) this.width=650; "class=" AlignCenter size-full wp-image-720 "src=" http://www.aliyue.net/wp-content/uploads/2016 /03/ion.gif "alt=" Ion
Set the spinner style in the theme stylename= "Apptheme"Parent= "Theme.AppCompat.Light.NoActionBar"> Spinner Style - Itemname= "Android:dropdownlistviewstyle">@style/xzfspinnerstyleItem> style> stylename= "Xzfspinnerstyle"Parent= "Android:Widget.ListView.DropDown"> Separator Line Color - Itemname= "Android:divider">#00ff00Item> Itemname= "Android:dividerheight">1d
Android spinner automatically pops up the list and sets the title. ttextview does not wrap the automatic screenshot method. Search for Android spinner click on stackoverflow to obtain the available result. javasmclick (); // you can set the title.
Spinner. setprompt ("My title ");
The pop-up list cannot be listened to when you press the rollback key for the fir
Custom pull-down style Spinner and androidspinner in Android
Custom pull-down style Spinner in Android
This article continues to introduce the android custom control series and the use of custom Spinner controls.
Implementation
1. Define the drop-down control layout (ListView and child control layout)
2. Custom SpinerPopWindow class
3. Define the Adapter for da
Recently in the project has a lot of drop-down box, in order to realize the convenience of using the Android spinner, but the spinner style does not meet the requirements, and then learn the custom spinner. Here's the whole step:
1. Get the picture ready.
Defined in 2.style
3. Call
4. Define Simple_spinner_item.xml in Layout
5.java Code
arrayadapter
Effec
Here is the main implementation of the spinner style in theme, as followsAs for how layout layouts, there is no way to find it. By looking at the code you know, if you are using the dialog form, then this layout is actually implemented in dialog, because it is called dialogAndroid-spinner Style Implementation
The method of removing the dividing line has been found for a long time, and finally found a way to change the split lineThe spinner and Autocompletetextview hint list has a black dividing line in the middle, and if you want to change its color value, rewrite the style.1. Write a style in themes 2. The style is called in the manifest of the activity where the control resides The list is the style without the split line.Change the color of
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.