0

i have problem with radiogroup and radiobutton that always sending a same value

the xml code look like this

  <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:orientation="horizontal">

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

                <RadioButton
                    android:id="@+id/radioPria"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="10dp"
                    android:button="@drawable/bg_selector_radiobutton"
                    android:checked="true"
                    android:text="Male"
                    android:textColor="@color/color_text_font_login"
                    android:textSize="14sp" />

                <RadioButton
                    android:id="@+id/radioWanita"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:button="@drawable/bg_selector_radiobutton"
                    android:text="Female"
                    android:textColor="@color/color_text_font_login"
                    android:textSize="14sp" />

            </RadioGroup>
  </LinearLayout>

and the snippet code is

   jeniskelamin = (RadioGroup) findViewById(R.id.radiogender);


    if (jeniskelamin.getCheckedRadioButtonId() == R.id.radioPria) {
        gender = "male";
    } else if (jeniskelamin.getCheckedRadioButtonId() == R.id.radioWanita) {
        gender = "female";
    } else gender = null;

no matter which radiobutton i choose the value always sending "male" help out here thanks for your help in advance!

0 Answers0