views:

35

answers:

1

what would be the correct way of receiving and sending a event when a check box get's enable or disable. In c# i could just easily double click and all the code would be done for me. but in android it appears to be a bit more obscure. i thought of using the touch event handlers but then if the user has a keyboard it wont detect the change since it's not touch. I figure android should have a native event for check box state change.

+3  A: 
CheckBox repeatChkBx = ( CheckBox ) findViewById( R.id.repeat_checkbox );
repeatChkBx.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
    {
        if ( isChecked )
        {
            // perform logic
        }

    }
});

It's nothing personal buddy, but that's what I hate of those great IDEs... it makes things so easy that programmers don't understand what's going on in the background.

Cristian