java - After selecting items in the Spinner, it is not getting reflected to me (not visible to naked eye) -


i working on project in need dynamically add textview , spinner well. able add these 2 things dynamically program successfully.

now when trying select items in spinner, items not getting shown in emulator items selected gets shown in toast.

does need make item selected in spinner?

for (map.entry<string, string> entry : mapcolumns.entryset()) {      spinnerarray = new arraylist<string>();      final textview rowtextview = new textview(cont);     final spinner spinner = new spinner(cont);      rowtextview.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content));     spinner.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content));      for(string s: entry.getvalue().split(",")) {         system.out.println(s);         s = s.replaceall("[^a-za-z0-9]+","");          spinnerarray.add(s);     }      arrayadapter<string> spinnerarrayadapter = new arrayadapter<string>(cont, android.r.layout.simple_spinner_dropdown_item, spinnerarray);      rowtextview.settext(entry.getkey());     rowtextview.settypeface(null, typeface.bold);     spinner.setadapter(spinnerarrayadapter);      // add listener     spinner.setonitemselectedlistener(new customonitemselectedlistener());      layout.addview(rowtextview);     layout.addview(spinner); }  class customonitemselectedlistener implements onitemselectedlistener {      public void onitemselected(adapterview<?> parent, view view, int pos,             long id) {         toast.maketext(                 parent.getcontext(),                 "onitemselectedlistener : "                 + parent.getitematposition(pos).tostring(),                 toast.length_short).show();     }      @override     public void onnothingselected(adapterview<?> arg0) {         // todo auto-generated method stub     } } 

below xml layout-

<?xml version="1.0" encoding="utf-8"?>     <scrollview xmlns:android="http://schemas.android.com/apk/res/android"         android:layout_width="fill_parent"         android:layout_height="fill_parent" >          <linearlayout             xmlns:android="http://schemas.android.com/apk/res/android"             android:id="@+id/llayout"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:orientation="vertical" >              <button                 android:id="@+id/button1"                 android:layout_width="100px"                 android:layout_height="wrap_content"                 android:layout_gravity="center_vertical|center_horizontal|center"                 android:gravity="center_vertical|center_horizontal"                 android:text="save" />          </linearlayout>      </scrollview> 

here mapcolumns hev key-value pair. in spinner items getting shown value of map.

problem statement:-

now need make sure if selecting items in spinner, should selected , visible other person.

below image in have selected items in spinner not getting shown , textview light in color-

enter image description here

enter image description here

the below code using populate spinnerarray looks suspicious because remove characters string.

for(string s: entry.getvalue().split(",")) {     ///system.out.println(s); move print statement below line , see prints in logs     s = s.replaceall("[^a-za-z0-9]+","");      system.out.println(s);      spinnerarray.add(s); } 

so if spinnerarray provided empty string come empty spinner. suggest comment out whole block , try app , see if problem persist.

if want spinner comeup selected item add following line:

  spinner.setselection (0); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -