android how do you dynamically change a radiogroup based on the radiogroups selection
<p>I get an error on the "button2.setOnClickListener(<strong>radio_listener</strong>);" </p>

<p>Because its embedded inside the onclick listener calling itself, whats the way around this?</p>

<pre><code>    final RadioGroup rGroup3 = (RadioGroup) findViewById(R.id.radio_gcam);

    OnClickListener radio_listener = new OnClickListener() {

        public void onClick(View v) {
            RadioButton button = (RadioButton) v;
            no_of_gcams = 3;
            gcam_names_array[0] = "Machine 1";
            gcam_names_array[1] = "Machine 2";
            gcam_names_array[2] = "Machine 3";
            gcam_names_array[3] = "Machine 4";

            for (int i = 0; i &lt; no_of_gcams; i++)
            {

            RadioButton button2 = new RadioButton(ModbusDroid.this);
            button2.setText(gcam_names_array[i]);
            button2.setOnClickListener(radio_listener);      
            rGroup3.addView(button2);

            }
        }
    };

    if (no_of_gcams == 0)
    {
    RadioButton button1 = new RadioButton(this);
    button1.setText("Setup a G-CAM");

    button1.setOnClickListener(radio_listener);
    rGroup3.addView(button1);}
</code></pre>
