Android - How to enable a button if a radio button is checked?
<p>I want to know/learn how to enable a button when/if a radio button is checked</p>

<p><strong>Steps done</strong></p>

<p>I created a <strong>fragment</strong> and inside a radio group with 3 radio buttons inside</p>

<p><strong>Goal</strong></p>

<p>My main goal is to enable the button when a radio button is checked, and disable it when the radio button is unchecked</p>

<p><strong>Code</strong></p>

<p>So far I have this code</p>

<pre><code>public class Operations extends Fragment
{
    RadioButton surfArea, rad, diam;
    RadioGroup radG;
    Button openSelect;

    public Operations()
    {
        // Required empty public constructor
    }

    public static Operations newInstance()
    {
        return new Operations();
    }

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater,
                             ViewGroup container,
                             Bundle savedInstanceState)
    {
        View rootView = inflater.inflate(R.layout.fragment_operations_sphere, container, false);

        surfArea = (RadioButton) rootView.findViewById(R.id.RB_surfArea);
        rad = (RadioButton) rootView.findViewById(R.id.RB_Rad);
        diam = (RadioButton) rootView.findViewById(R.id.RB_Diam);
        openSelect = (Button) rootView.findViewById(R.id.btn_open_select);

        radG = (RadioGroup) rootView.findViewById(R.id.RG_group);

        openSelect.setEnabled(false);

        openSelect.setOnClickListener(new View.OnClickListener()
        { //This piece of code is for testing purposes
            @Override
            public void onClick(View v)
            {
                if (surfArea.isChecked())
                {
                    openSelect.setEnabled(true); //I detected my mistake here, so I would like to know a better way to achieve this
                    Intent sa = new Intent(getContext(), OperSphere.class);
                    startActivity(sa);
                }
            }
        });

        return rootView;
    }

    @Override
    public void onResume()
    { //Here the radio button unchecks
        radG.clearCheck();
        super.onResume();
    }
}
</code></pre>

<p>Question</p>

<p>How to enable a button when a radio button is checked?</p>

<p>Some examples would be great</p>

<p>Thanks in advance</p>