java - Android Spinner not showing up -


can tell me why spinners not showing up? i'm doing exercise , don't understand why spinners show no items @ all. 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);        }  } 

your code populate spinners looks fine (i think),maybe problem on layout xml?, why don't try using array of strings instead? here, plus use resource values, think better not creating stuff @ runtime.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -