public void EnollmentUser() {
JSONObject mDataJO = new JSONObject();
String adress = etmapname.getText().toString();
String adress_descript = etadress.getText().toString();
String roomInfo = etroomInfo.getText().toString();
String described = etdescribed.getText().toString();
String apartment = etRb.getText().toString();
String hous = etRb1.getText().toString();
int ug_include = etRgrp.getCheckedRadioButtonId();
int deposit = Integer.parseInt(etPrice.getText().toString());
int monthly_rent = Integer.parseInt(etmonthly_rent.getText().toString());
int acreage = Integer.parseInt(etacreage.getText().toString());
try {
mDataJO.put("adress",adress);
mDataJO.put("adress_descript",adress_descript);
mDataJO.put("deposit",deposit);
mDataJO.put("roomInfo",roomInfo);
mDataJO.put("described",described);
mDataJO.put("monthly_rent",monthly_rent);
mDataJO.put("acreage",acreage);
mDataJO.put("ug_include",ug_include);
mDataJO.put("apartment",apartment);
mDataJO.put("hous",hous);
mDataJO.put("img",img);
Log.e("dh","server req:\n"+mDataJO.toString());
} } catch (JSONException e) {
e.printStackTrace();
}
....
I'd like to add a radio button to Jason. There are two radio buttons and they're grouped into radio groups of radios.
I want Jason to save the radio button that I checked Both are saved.
How can I save only the radio button I checked in Jason? I beg of course.
android
As you used in the above code, you can use etRgrp.getCheckedRadioButtonId()
to determine the currently checked radio button. I don't think there's a problem with the code, but it's strange that both can be saved. See what values are assigned to ug_include
by logging or debugging.
If there is no radio button selected, the getCheckedRadioButtonId() function returns -1, so check this as well.
© 2024 OneMinuteCode. All rights reserved.