문제

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