Java 检查BMI按钮的性别

Java 检查BMI按钮的性别,java,android,if-statement,button,Java,Android,If Statement,Button,我有一个代码,我被困在我不知道怎么做的事情上。 我必须用java开发一个理想体重的应用程序,其中男性计算(72.7身高)-58,女性计算(62.1身高)-44.7。 我为性爱创建了一个单选按钮,但我不知道该把我找到的if代码放在哪里。我感谢你的帮助 activity_main.xml <RadioGroup android:id="@+id/rgSexo" android:layout_width="wrap_

我有一个代码,我被困在我不知道怎么做的事情上。 我必须用java开发一个理想体重的应用程序,其中男性计算(72.7身高)-58,女性计算(62.1身高)-44.7。 我为性爱创建了一个单选按钮,但我不知道该把我找到的if代码放在哪里。我感谢你的帮助

activity_main.xml

 <RadioGroup
            android:id="@+id/rgSexo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <RadioButton
                android:id="@+id/rbMasculino"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true"
                android:text="Masculino" />

            <RadioButton
                android:id="@+id/rbFeminino"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Feminino" />
        </RadioGroup>
问题是,我到底要把这个放在哪里

public void onRadioButtonClicked(View v)
    {
        //require to import the RadioButton class
        RadioButton rb1 = (RadioButton) findViewById(R.id.Radio_one);
        RadioButton rb2 = (RadioButton) findViewById(R.id.Radio_two);

        //is the current radio button now checked?
        boolean  checked = ((RadioButton) v).isChecked();

        //now check which radio button is selected
        //android switch statement
        switch(v.getId()){

            case R.id.Radio_one:
                if(checked)
                    //if first selected
                break;

            case R.id.Radio_two:
                if(checked)
                    //if second selected

                break; 
        }
public void onRadioButtonClicked(View v)
    {
        //require to import the RadioButton class
        RadioButton rb1 = (RadioButton) findViewById(R.id.Radio_one);
        RadioButton rb2 = (RadioButton) findViewById(R.id.Radio_two);

        //is the current radio button now checked?
        boolean  checked = ((RadioButton) v).isChecked();

        //now check which radio button is selected
        //android switch statement
        switch(v.getId()){

            case R.id.Radio_one:
                if(checked)
                    //if first selected
                break;

            case R.id.Radio_two:
                if(checked)
                    //if second selected

                break; 
        }