android - Get all the selected radio button and check box value created dyamically? -
I want to save all the selected responses (checkboxes and radiobuttons) and its related question that is set in the dynamic text view of sqlite db , But the problem is that when I'm clicking on "Save Button", only the last selected radio button value is saved on the highlight, not all the selected values and not able to get all the selected check box values is.
Please help me. > Save = (Button) findViewById (R.id.save); Save.setOnClickListener (this); Ll = (LinearLayout) findViewById (R.id.linearLayout1); For (int j = 0; j and lt; question length; j ++) {tv = new textview (this); Tv.setId (j); Tv.setText (question [j] .get quiz (not +) + "." + Question [j] .get question ()); Ll.addView (TV); Answer [] Answer = Question [j] GetAnswer (); If (question [j] .getMultipleChoice (.) Ignore equally ("wrong")) {RG = new radio group (this); Rg.setOrientation (RadioGroup.VERTICAL); Radiobutan [] RB = new radio button [answer.lambi]; For (Int i = 0; I & lt; answer.length; i ++) {// radio button RB [i] Add = New radio button (this); Rb [i] .setText (Answer [i] .getLabel ()); Int id = integer Kprsent (J + "+ + I); rb [i] .setId (ID); rg.addView (rb [i]);} Ll.addView (rg); Else {// (Int i = 0; i & lt; answer.length; i Add Czech box ++) {cb = new checkbox (this); cb.setText (North [i] .getLabel ()); Int id = integer Kprsent ( J + "+ + I); Cb.setId (id); Ll.addView (CB); }}} Public on zero (see V) {switch (VkgetId ()) {case Arkaid. Save: if (rg.getCheckedRadioButtonId ()! = -1) {int id = rg.getCheckedRadioButtonId () ; View radio distribution = RGFindiaId; Int radioId = rg.indexOfChild (radio button); Radiobutton BTN = (radio button) RG .get childat (radio id); String Answer = (string) BTN.Get Text (); // Only the last selected radio button value is coming // // Not able to receive all the selected checkbox values; Default: Break; }}
I do not know Android. But this problem produces me in Struts 2 . I have solved that problem by generating dynamic checkboxes like below.
& lt; S: iterator value = "samplelist" & gt; & Lt; Input type = "checkbox" value = "true" style = "margin-top: 2px;" Name = "p_": asset value = 'profile id' / & gt; & lt; / s: iterator & gt;
So I have found out that this is Java code in went to Czech or not to loop
(int i = 0; i & lt; samplelist.size (i ++) request.getParameter ( "P_something"); < / Code>
Comments
Post a Comment