Spinner: Spinner provides a quick way to select one value from a set of values. Android spinners are nothing but the drop-down-list seen in other programming languages. In a default state, a spinner shows its currently selected value. It provides an easy way to select a value from a list of values.


Step 1: Create a project, Open res -> layout -> activity_main.xml and paste this code below or you simple drag and drop spinner from widget window to app layout.

Step 2: Open app-> java -> package -> MainActivity.java and Add the below to code in it.


Decode the Code: Here in the project we got the reference or object of spinner by using findViewById(R.id.spinner)  then we set the OnClickListener to object reference of the spinner.To populate data into spinner we use ArrayAdapter.ArrayAdapter is like mobile adapter which holds all parameters like which layout is used for populating and source of data which may a string[] or ArrayList.Then we have set ArrayAdapter to Spinner.