Collecting data from multiple radio button groups in Android -
i have master-detail layout. master flow implemented using list fragment, , detail fragment radio button group. layout looks that:
for each option in list fragment there corresponding detail fragment radio button group. want collect checked (selected) radio button when submit
button clicked. ideally array of checked radio buttons.
what best approach problem?
try use hashmap add selected option key , value pair, when radio button checked
map<string, string> mapoption=new hashmap<string, string>(); if(rboption1.ischecked()){ log.v(tag+".onclick", "option 1 selected"); optionselect=1; mapoption.put(string.valueof(rank), string.valueof(optionselect)); } else if(rboption2.ischecked()){ log.v(tag+".onclick", "option 2 selected"); optionselect=2; mapoption.put(string.valueof(rank), string.valueof(optionselect)); } else if(rboption3.ischecked()){ log.v(tag+".onclick", "option 3 selected"); optionselect=3; mapoption.put(string.valueof(rank), string.valueof(optionselect)); } else if(rboption4.ischecked()) { log.v(tag+".onclick", "option 4 selected"); optionselect=4; mapoption.put(string.valueof(rank), string.valueof(optionselect)); } else { log.v(tag+".onclick", "no option selected"); optionselect=0; mapoption.put(string.valueof(rank), string.valueof(optionselect)); }
Comments
Post a Comment