Populate android spinner dynamically -


i have created text view in android code below:

 linearlayout ll = new linearlayout(this);         ll.setorientation(linearlayout.vertical);         sv.addview(ll);  txtv = new textview(this); txtv.settext("text"); ll.addview(txtv);      

same way have created spinner:

spinner = new spinner(this); ll.addview(spinner); 

but unable populate value on spinner. tutorials giving populating spinner array adapter taking id of xml, r.id. .... since creating dynamic cant way. how can populate spinner dynamically?

you can store values in string array use array populate spinner.

like string[] value = new string[]{ "one","two","three".....};

try arraylist<string> list=new arraylist<string>();

list.add(your_value); 

then string[] value=list.toarray();


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -