Frage

I have a customized RadioGroup and like to execute some code when one off the buttons is clicked regardless if it did change the state or not. The onCheckedChanged Event is only triggered when a new selection is done and the onClick events seems never to be triggered. How can I solve this issue?

War es hilfreich?

Lösung

int count = radioGroup.getChildCount();
for (int i=0;i<count;i++) {
    View o = radioGroup.getChildAt(i);
    if (o instanceof RadioButton) {
        o.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                //your code here
            }
        });
    }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top