How to receive a event on android checkbox check change?
Solution 1:
CheckBox repeatChkBx = ( CheckBox ) findViewById( R.id.repeat_checkbox );
repeatChkBx.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if ( isChecked )
{
// perform logic
}
}
});
Solution 2:
Since CheckBox (eventually) extends View, you can use a standard OnClickListener to detect when the CheckBox is actually tapped by the user (as opposed to the ListView updates):
CheckBox repeatChkBx = ( CheckBox ) findViewById( R.id.repeat_checkbox );
repeatChkBx.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if ( ((CheckBox)v).isChecked() ) {
// perform logic
}
}
});