Thursday, March 29, 2012

Bind Spinner (Dropdown) Android

As a beginner, It is difficult to bind the data to Spinner (Drop down). If we consider HTML, it is easy to add option values to the drop down. But In Android, we have to use Adapters to bind the data. So here I am targeting my approaches to bind to the Spinner. 

Binding static Array to the spinner

static final String[] COUNTRIES = new String[] { "India", "US", "UK",
   "Sri Lanka", "Austraila", "Denmark", "Saudi" };

Spinner spCountry = (Spinner) findViewById(;

ArrayAdapter<CharSequence> adCountry = new ArrayAdapter<CharSequence>(
                this, android.R.layout.simple_spinner_dropdown_item, COUNTRIES);  


Binding resource Array to the Spinner

Spinner spCities = (Spinner) findViewById(;

String[] cities = getResources().getStringArray(R.array.arr_cities);

ArrayAdapter<CharSequence> adCities = new ArrayAdapter<CharSequence>(
       this, android.R.layout.simple_spinner_item, cities);



Binding resource Array to the Spinner Using ArrayAdapter.createFromResource

Spinner spLocalities = (Spinner) findViewById(;

ArrayAdapter<CharSequence> adLocalities = ArrayAdapter
   .createFromResource(this, R.array.arr_localities,android.R.layout.simple_spinner_item);



References : download_source_code


  1. Thank you so much for sharing this worth able content with us. The concept taken here will be useful for my future programs and i will surely implement them in my study. Keep blogging article like this.

    Android Online Training

  2. Not only do variations in hardware and software affect the overall compatibility of the app, it reflects poorly on the build quality of the app.gerald winata gozali

  3. Informative post indeed, I’ve being in and out reading posts regularly and I see alot of engaging people sharing things and majority of the shared information is very valuable and so, here’s my fine read.
    click here to continue your registration
    click here to confirm
    click here download
    click here digital
    click here download cb background

  4.  I just stumbled upon your weblog and wanted to publicize that i've without a doubt enjoyed browsing your weblog posts. 먹튀