Q: Android Spinner not showing up Can anyone tell me why my spinners are not showing up? I'm doing an exercise and I don't understand why my spinners show no items at all. any suggestions?
import android.app.Activity;
import android.os.Bundle;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import java.util.*;

public class Length extends Activity{

    private Spinner spi1,spi2,cmbOpciones;
    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.length);

    //Spinner1
    List<String> imperialunits = new ArrayList<String>();
    imperialunits.add("inch");
    imperialunits.add("foot");
    imperialunits.add("yard");
    imperialunits.add("mile");

    ArrayAdapter<String> adaptador = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, imperialunits);

    spi1=(Spinner)findViewById(R.id.spinner1);

    adaptador.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spi1.setAdapter(adaptador);

    //Spinner2
    final String[] SIunits =
             new String[]{"km","m","cm"};

    ArrayAdapter<String> adaptador2 = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, SIunits);
    spi2 = (Spinner)findViewById(R.id.spinner2);
    adaptador2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spi2.setAdapter(adaptador2);

    //Spinner 3
    final String[] datos = new String[]{"Elem1","Elem2","Elem3","Elem4","Elem5"};

    ArrayAdapter<String> adaptador3 = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, datos);

    cmbOpciones = (Spinner)findViewById(R.id.CmbOpciones);

    adaptador.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    cmbOpciones.setAdapter(adaptador3);
       }

}


A: Your code to populate the Spinners looks fine (I think),maybe your problem is on your layout xml?, but why don't you try using an array of strings instead? like here, plus you get to use resource values, I personally think its better not creating stuff like that at runtime.

A: I tested your code and works perfectly. I agree, it must be something wrong in your xml file.
