0

Was wondering if I could define the onCheckChanged method in the layout xml file in android for a RadioGroup? As it stands I have done this programmatically with

rgroup.setOnCheckedChangeListener(this);

followed by coding my onCheckedChanged() method, and it works perfectly as intended. Again, just wondering if I could do it in the XML similar to a Button, (android:onClick=methodName)

codeMagic
  • 44,549
  • 13
  • 77
  • 93
user1759942
  • 1,322
  • 4
  • 14
  • 33

1 Answers1

0

You can define an onClick for each RadioButton in your xml. I'm not really sure of any benefits/disadvantages of this. But there doesn't appear to be anything like that for the RadioGroup. Its not necessarily going to know that one in the group was "changed" but that this RadioButton was checked

Docs

codeMagic
  • 44,549
  • 13
  • 77
  • 93
  • I thought that but wasnt sure about it. It does make even more sense to do that though because then rather than a case structure to evaluate which radio was selected i simply assign each their own onClick and eliminate the need for conditionals. THANKS! :D – user1759942 Feb 23 '13 at 20:54
  • No, problem. Glad I could clear it up for you. I guess something like that is developer preference in most cases – codeMagic Feb 23 '13 at 21:10