How to programmatically select RadioButton in an activity

Barbie

In my project, I get the value of the gender from the database as 0 and 1.
0 for male and 1 for female.
Based on this values, I need to check the corresponding RadioButton in a RadioGroup.
If 0 is pressed, radio0 will be checked or radio1 will be checked.
I don't know how to check the radio button based on this 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 it fails. Can anyone help me?

Talha Q

Try this.

   if(gendd.contains("0"))
    {
       male.setChecked(true);
       female.setChecked(false);
   }
   else
   {
       male.setChecked(false);
       female.setChecked(true);
  }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to programmatically select RadioButton in an activity

From Dev

How to check RadioButton of other Activity

From Dev

How to check RadioButton of other Activity

From Dev

MS Excel - How to select a radioButton when click on cell not on the radioButton itself

From Dev

How to select just a radiobutton in a repeater with postback

From Dev

RadioButton check programmatically

From Dev

How to programmatically change the background image of an Android Activity

From Dev

How to take screenshot of WHOLE activity page programmatically?

From Dev

How to resume Android Activity programmatically from background

From Dev

How to remove an activity from showing in the Launcher programmatically?

From Dev

How to select item in collectionview programmatically?

From Dev

How to select ListView items programmatically?

From Dev

how to multiple select programmatically in PowerPoint

From Dev

How to select system font programmatically?

From Dev

How to select ListView items programmatically?

From Dev

How to select a uitableview cell programmatically?

From Dev

Android RadioButton not grouped together programmatically

From Dev

How to force RadioGroup to select only one RadioButton at a time programatically?

From Dev

How to pre-select radiobutton- / checkbox-group in the playframework?

From Dev

select a specific radiobutton in a form

From Dev

Select a tk radiobutton at startup

From Dev

radiobutton is not selected while select radiobutton in listview

From Dev

How to get activity title name through programmatically java android

From Dev

How to programmatically correct the landscape to portrait error for fragment activity

From Dev

how to turn On/off Activity Recognition in google Api Client Programmatically

From Dev

How can I configure Launcher activity programmatically in android?

From Dev

How to programmatically correct the landscape to portrait error for fragment activity

From Dev

How to get activity title name through programmatically java android

From Dev

How can I find android apk installation activity programmatically?

Related Related

  1. 1

    How to programmatically select RadioButton in an activity

  2. 2

    How to check RadioButton of other Activity

  3. 3

    How to check RadioButton of other Activity

  4. 4

    MS Excel - How to select a radioButton when click on cell not on the radioButton itself

  5. 5

    How to select just a radiobutton in a repeater with postback

  6. 6

    RadioButton check programmatically

  7. 7

    How to programmatically change the background image of an Android Activity

  8. 8

    How to take screenshot of WHOLE activity page programmatically?

  9. 9

    How to resume Android Activity programmatically from background

  10. 10

    How to remove an activity from showing in the Launcher programmatically?

  11. 11

    How to select item in collectionview programmatically?

  12. 12

    How to select ListView items programmatically?

  13. 13

    how to multiple select programmatically in PowerPoint

  14. 14

    How to select system font programmatically?

  15. 15

    How to select ListView items programmatically?

  16. 16

    How to select a uitableview cell programmatically?

  17. 17

    Android RadioButton not grouped together programmatically

  18. 18

    How to force RadioGroup to select only one RadioButton at a time programatically?

  19. 19

    How to pre-select radiobutton- / checkbox-group in the playframework?

  20. 20

    select a specific radiobutton in a form

  21. 21

    Select a tk radiobutton at startup

  22. 22

    radiobutton is not selected while select radiobutton in listview

  23. 23

    How to get activity title name through programmatically java android

  24. 24

    How to programmatically correct the landscape to portrait error for fragment activity

  25. 25

    how to turn On/off Activity Recognition in google Api Client Programmatically

  26. 26

    How can I configure Launcher activity programmatically in android?

  27. 27

    How to programmatically correct the landscape to portrait error for fragment activity

  28. 28

    How to get activity title name through programmatically java android

  29. 29

    How can I find android apk installation activity programmatically?

HotTag

Archive