Android spinners are Linear Vertical Drop Down List in Android which provide the multiple selection to the user from the drop down list. It provides multiple options from the drop down items to perform various action according to the items.
Create a new android project name SpinnerExample .

Add a spinner object to your layout as shown below in your activity_main.xml file.
Declare an array string in string.xml file in values.
Go to project folder(SpinnerExample) res/values/string.xml
provide name to array string through which you can refer that string. lets say you are creating an array string of colors.
Note : This source needs to be bound with the spinner through ArrayAdapter.
Create a new xml. file in layout folder to display the contents of array. ,best way to display items in a list is in TextView form.
go to project folder(SpinnerExample)/res/layout/itemlist.xml
Put the following code in MainActivity.java ....
Result :

Download Source code : SpinnerExample.rar


0 comments:
Post a Comment