In my project, I get the gender value from the database as 0 and 1.
0 for men and 1 for women.
Based on these values, I need to check the corresponding RadioButton in the RadioGroup.
If you press 0, the value of radio0 will be checked or radio1 will be checked.
I don't know how to test a switch based on these string values ββ...
This is the code I tried:
String gendd=ViewProfileActivity.participantview.get(4); System.out.println("Gender:::::"+gendd); male=(RadioButton)findViewById(R.id.radio0); female=(RadioButton)findViewById(R.id.radio1); if(gendd.equals("0")){ male.setSelected(true); female.setSelected(false); } else { male.setSelected(false); female.setSelected(true); }
But that fails. Can anybody help me?
android selected button radio
Barbie
source share