android - Radio Group value selection issue -


i have following radiogroup:

<radiogroup             android:id="@+id/radiogroup1"             android:layout_width="wrap_content"             android:layout_height="wrap_content" >              <radiobutton                 android:id="@+id/rd_male"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:checked="true"                 android:text="male" />              <radiobutton                 android:id="@+id/rd_female"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="female" />         </radiogroup> 

i want selected value in radio group, hence written following code in oncreate method:

 int checkedradiobutton = rggender.getcheckedradiobuttonid();               switch (checkedradiobutton) {             case r.id.rd_male : gender = "female";                                       break;             case r.id.rd_female : gender = "male";                                      break;            } 

but every time finds value of variable gender "female" (although selects male)

what wrong in code? please me.

simple mistake

switch (checkedradiobutton) {             case r.id.rd_male : gender = "male";                                       break;             case r.id.rd_female : gender = "female";                                      break;            } 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -