I am developing a android application in which I am creating different dynamic form controls of different forms from the JSON data at runtime. The form may contain EditText, Spinner, Chechboxlist, Radiobuttonlist or five Addressboxes of EditText. Each control may also appear multiple times in different order. Now, I have generated and displayed the form controls of different forms at runtime.
One Example Form :
TextBox1 : ___________
Spinner2 : Item1 Item2 Item3
TextBox3 : ___________
Checkbox4 :
- Option1
- Option2
- Option3
Radiogroup5 :
- Radio1
- Radio2
Spinner6 : Item1 Item2
Checkbox7 :
- Option1
- Option2
Radiogroup8 :
- Radio1
- Radio2
Address9 : _____________ _____________ _____________ _____________ _____________
Here Address contains five EditText consecutively.Now other form may or may not contain this controls.Here TextBox1, Spinner2, TextBox3 etc are the unique label to identify the control. But my problem is to submit the data entered in the form. The form contains a submit button. By pressing it, I have to send POST JSON Request by form the JSON with the filled data.
Example JSON Request :
{ "FormData" : {
{"Name":"TextBox1" , "Value":"DummyText"},
{"Name":"Spinner2" , "Value":"Item3"},
{"Name":"TextBox3" , "Value":"DummyText"},
{"Name":"Checkbox4" , "Value":"Option2, Option3"},
{"Name":"Radiogroup5" , "Value":"Radio2"},
{"Name":"Spinner6" , "Value":"Item1"},
{"Name":"Checkbox7" , "Value":"Option1"},
{"Name":"Radiogroup8" , "Value":"Radio1"},
{"Name":"Address9" , "Value":"Dummy1, Dummy2, Dummy3, Dummy4,Dummy5"}
}
So how to write the proper single code for storing and submitting that data for a particular dynamic form in a data structure in such a way that I can form that JSON Request? Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire