Android - Spinner

Android Spinner is just like the combox box or drop down menu of AWT or Swing in java. It is used to display multiple options to the user in which only one item can be selected by him. Android spinner is associated with AdapterView to retrive the list of items. So you need to use one of the adapter classes with spinner.Adapter classes is responsible for Layout design and contents of spinner widget. Android Spinner class is the subclass of AsbSpinner class.

Create a New Android Project

Open Android Studio and create a new Project to test ImageView UI Widget.

You can view this blog to know how to create a Project in Android

Make Design for XML Layout

Open activity_main.xml from android resources and remove everything.Drag an Relative Layout and then drag a Spinner on Layout in Graphical mode of IDE.
<RelativeLayout xmlns:android=""
    tools:context="dzone.jaipur.myapp1.MainActivity" >

        android:layout_marginTop="83dp" />


Code in you Activity Class

Your java File (Android Activity) should look like this..

public class MainActivity extends AppCompatActivity {

  String[] country = { "India", "USA", "China", "Japan", "Other",  };

	protected void onCreate(Bundle savedInstanceState) {

    Spinner spin = (Spinner) findViewById(;

        //Creating the ArrayAdapter instance having the country list
        ArrayAdapter aa = new ArrayAdapter(this,android.R.layout.simple_spinner_item,country);
        //Setting the ArrayAdapter data on the Spinner

    public void onItemSelected(AdapterView arg0, View arg1, int position,long id) {
        Toast.makeText(getApplicationContext(),country[position] ,Toast.LENGTH_LONG).show();

    public void onNothingSelected(AdapterView arg0) {
        // TODO Auto-generated method stub




Program output on emulator screen

Now Run the Application on your virtual device and get the desired output.


cialis daily australia viagra effekt levitra eller cialis kamagra prezzo nuovo cialis cialis vs viagra levitra kaufen cialis 20 mg cialis kaufen viagra pour femme cialis 5 mg kamagra online levitra prijs cialis online viagra kopen kamagra bijsluiter kamagra online viagra generique kamagra gel pas cher levitra online uk viagra wirkung kamagra bestellen Viagra online