Pergunta

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)

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top