CheckBox click event is not working in android 4.4.2
holder.addcheck.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Testing", Toast.LENGTH_SHORT).show();
}
});
You can also use SetOnClickListener
addcheck= (CheckBox) findViewById(R.id.addcheck);
holder.addcheck.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//is addcheckchecked?
if (((CheckBox) v).isChecked()) {
Toast.makeText(MyAndroidAppActivity.this,
"Testing this checkbox", Toast.LENGTH_LONG).show();
}
}
});
And also you can use onCheckedChanged
check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Toast.makeText(MyAndroidAppActivity.this,
"Testing this checkbox", Toast.LENGTH_LONG).show();
}
});
Try this;
checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Toast.makeText(getApplicationContext(), "Testing", Toast.LENGTH_SHORT).show();
}
});
holder.addcheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Toast.makeText(getApplicationContext(), "Checked", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "Unchecked", Toast.LENGTH_SHORT).show();
}
}