How to check if android checkbox is checked within its onClick method (declared in XML)?
try this one :
public void itemClicked(View v) {
//code to check if this checkbox is checked!
CheckBox checkBox = (CheckBox)v;
if(checkBox.isChecked()){
}
}
This will do the trick:
public void itemClicked(View v) {
if (((CheckBox) v).isChecked()) {
Toast.makeText(MyAndroidAppActivity.this,
"Checked", Toast.LENGTH_LONG).show();
}
}