Dynamic Spinner

This example will show how to create spinner with list view at run time in android. In this example you will be able to assign the contents of a spinner to another spinner at run time on a button click.


  1. Create a new project by File-> New -> Android Project name it DynamicSpinner.
  2. Write following into main.xml:



  1. Run for output.


  1. Create a project named DynamicSpinner and set the information as stated in the image.

Build Target: Android 4.2
Application Name: DynamicSpinner
Package Name: com.example.DynamicSpinner
Activity Name: DynamicSpinnerActivity

  1. Open DynamicSpinnerActivity.java file and write following code there:



  1. Compile and build the project.

Leave a Comment: