Android ListView Response -


i have created listview using arrayadapter. contains

  1. a textview

  2. two radio button (i.e radio group)

  3. a edittext

also, added footer having submit button. textview setting dynamically.radiobuttons have yes , no value.

problem , on clicking submit button , want values listview send somewhere, getting null values radiobutton , edittext.

here code

    final question weather_data[] = new question[]             {             new question(str[0], r1, r2, etext, radio_group),             new question(str[01], r1, r2, etext, radio_group),             new question(str[02], r1, r2, etext, radio_group),             new question(str[03], r1, r2, etext, radio_group),             new question(str[04], r1, r2, etext, radio_group),             };      questionadapter adapter = new questionadapter(this,              r.layout.listview_item_row, weather_data);       listview1 = (listview)findviewbyid(r.id.securitylistview);      view header = (view)getlayoutinflater().inflate(r.layout.listview_header_row, null);     listview1.addheaderview(header);     view footer = (view)getlayoutinflater().inflate(r.layout.listview_footer_row, null);     listview1.addfooterview(footer);     button btnsubmit=(button)(footer.findviewbyid(r.id.submit));     listview1.setadapter(adapter);     question w1=    (question) listview1.getitematposition(2);      system.out.println(w1);     system.out.println(listview1.getparent().tostring());     system.out.println("child count "+listview1.getchildcount());       btnsubmit.setonclicklistener(new onclicklistener() {          public void onclick(view v) {             // todo auto-generated method stub             toast.maketext(getapplicationcontext(), "footer toast", toast.length_long).show();             system.out.println("in footer onclick");             toast.maketext(mainactivity.this,"footer toast", toast.length_long).show();              myque=(question) listview1.getitematposition(3);             system.out.println(((question) listview1.getitematposition(3)).editresponse.gettext()+" in edit text");             system.out.println(((question) listview1.getitematposition(3)).radioyes.ischecked());             // want these 2 lines print answer (values entered user). showing null or values set me @ runtime.          }     });  } 

}

so, there several ways of solving problem.

try items listview , them find text , boolean values:

        public void footerbuttonclick(){             for(int i=0;i<listview.getchildcount;i++){                 string text=((edittext)listview.getchildat(i).findviewbyid(r.id.your_edit_text_id)).                 gettext().tostring();                //and same radiogroups.              }          } 

or can try create static arrays of boolean , string values in mainactivity class , notify textwatchers edittexts , valuechangers radiogroups. , when text or boolean values changing change them in static arrays. can use arrays when you'll push button


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -