My Android spinner works without an ArrayAdapter...why? -


will come heaven or hell? had populate 5 spinners, tried compact code. didn´t understand why should use arrayadapter, dropped out, in spite tutorials use it. surpraised, worked. code showing 1 spinner:

 spinner s2_height = (spinner)findviewbyid(r.id.s2_height);     s2_height.setonitemselectedlistener(new onitemselectedlistener() {  //register callback invoked when item in adapterview has been selected.         public void onitemselected(adapterview<?> arg0, view arg1,  //callback method invoked when item in view has been selected                 int arg2, long arg3) {             mycalc();}         public void onnothingselected(adapterview<?> arg0) {         // todo auto-generated method stub          } }); 

this location in .java, dropped out arrayadapter section, normaly being in tutorials recomanded as:

arrayadapter<charsequence> adapter = arrayadapter.createfromresource(             this, r.array.height_array_id, android.r.layout.simple_spinner_item);    adapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item);    s2_height.setadapter(adapter); 

and surprisingly, worked, placed method mycalc displays itemposition on 5 spinners correctly. afraid i´ll drawback @ place, may @ changing colours, or text heights. has same problem?

will come heaven or hell?

that question priest, minister, rabbi, etc. not relevant question stackoverflow.

i didn´t understand why should use arrayadapter, dropped out

you not have use arrayadapter, have use form of spinneradapter populate spinner via setadapter(). otherwise, spinner empty. if spinner not empty, means called setadapter() on somewhere.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -