Android Spinner Dropdown Example

In this post, we are going to see about Android Spinner Dropdown example.

Android Spinner is a UI widget which have dropdown. Once you click on dropdown , you can select one option among various options. I am going to put static data in android spinner and select one of value from them.

Source code:

Step 1 :Creating Project

Create an android application project named “SpinnerDropdownExampleApp”.

Step 2 : Creating Layout

Change res ->layout -> activity_main.xml as below:

Step 3 : Creating MainActivity

Change src/main/packageName/MainActivity.java as below:
We have created ArrayAdapter and attached it with Spinner in similar way we have done for Simple Android ListView.
If you notice, we have also implemented OnItemSelectedListener for listening to item selection in drop down.

Step 4 : Running the app

When you run the app, you will get below screen:

Android Spinner dropdown example

When you click on dropdown and select china, you will get below screen.

Android spinner selection example

After selecting china, you will get below screen.

We are done with Android Spinner Dropdown Example. Please comment if you are facing any issue while implementing it.

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *