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)

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top