I'm making an application where groups of Radio Buttons are generated whose names and values depends on a json. But, I have a detail, if for example 3 groups of radio buttons are generated with 3 options each, what I want is to know that radio buttons was selected from each group. Any suggestions on how I can do it These can be 2 groups, 10 groups, etc.
LayoutInflater inflater = LayoutInflater.from(Vista_producto.this);
int id = R.layout.botones;
LinearLayout linearLayout = (LinearLayout) inflater.inflate(id, null, false);
TextView textView = (TextView) linearLayout.findViewById(R.id.textView3);
textView.setText(std_name);
RadioGroupt = (RadioGroup) linearLayout.findViewById(R.id.RadioGroup1);
//LinearLayout linearLayout1 = (LinearLayout) linearLayout.findViewById(R.id.layout1);
//RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT);
float density = getResources().getDisplayMetrics().density;
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
(int)(55*density),
(int)(45*density));
int margin = (int)(6*density);
params.setMargins(margin, margin, margin, margin);
i= i + 1;
layout.addView(linearLayout);
String std_item = jsonObject1.getString("std_item");
JSONObject js6 = new JSONObject(std_item);
int j = 0;
Iterator<String> keys1 = js6.keys();
while (keys1.hasNext()) {
String key1 = keys1.next();
Log.i("Parser", "objeto : " + key1);
JSONObject ke = js6.getJSONObject(key1);
String std_item_name = ke.getString("std_item_name");
Rboton = new RadioButton(getApplicationContext());
Rboton.setText(std_item_name);
Rboton.setId(j);
RadioGroupt.addView(Rboton);
//Rboton.setTextColor(Color.BLACK);
Rboton.setButtonDrawable(R.drawable.borde);
//Rboton.setButtonDrawable(R.drawable.boton_p);
Rboton.setBackgroundResource(R.drawable.rb_background_lluvia);
Rboton.setGravity(Gravity.CENTER);
Rboton.setTextColor(Color.BLACK);
Rboton.setLayoutParams(params);