As in previous tutorial we have seen selection of choices using android radio buttons, check boxes there is also a another type of option available spinners also called as android spinner.

Whenever we want to select a values out of a list of  available values spinner is one of the best available option.

Spinner consists of a list of values where user have to select a value, Spinner’s are generally used is form’s, selecting color, size, font and many other requirements.

A spinner has much more flexibility rather than other options because a spinner can be populated from even databases also we can change the design of android spinner dropdown style by using various themes available.

In this android tutorial we will see a spinner consists of android version’s and can select one out of it.

 

MainActivity.java

Spinner is loaded with bunch of strings store in a String array as

 

And this string array is in turn attached to a android spinner adapter as

 

 

Adding Spinner to our xml file.

 

activity_main.xml

strings.xml

add spinner in strings.xml file

 

AndroidManifest.xml

 

 

Output :

spinner1

 

spinner2

 

Any queries in this tutorial add comments below.

Also share the tutorial with your friends if you like it.

 

Show Buttons
Hide Buttons
Read previous post:
Android Tutorial on Radio-Button

Close