I got an error by using this code
holder.box.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean newState = !arrEmps.get(position).isChecked();
arrEmps.get(position).isChecked() = newState;
Toast.makeText(mContext.getApplicationContext(),
arrEmps.get(position).getName() + "check" + newState,
Toast.LENGTH_LONG).show();
}
});
the error line is
arrEmps.get(position).isChecked() = newState;
the error message is
Error:(86, 48) error: unexpected type
required: variable
found: value
I think you are using a default method from a clickable item, if so read this, if not go on
Referring to the Clickable interface, you can see that there are two methods:
isChecked()
is a getter and it only returns the value of the checked variable, as you can see inspecting(ie: it tells you whether a checkbox is checked or not):
@ViewDebug.ExportedProperty
@Override
public boolean isChecked() {
return mChecked;
}
There is also a setter,
setChecked(boolean checked)
This setter set the value of the property of the checked state of the clickable interface. (ie: is set a checkbox as checked or not)
If you are not using a default clickable item/view, but you have your own method
If the object you are using is a custom one, create a setter for the property you want to set by adding a setChecked(boolean value) method
public void setChecked(boolean value){
mValue = value;
}
here you can learn how to create getters and setters quickly
And I always reccomend this tutorial (imo the best) for learning android basics.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With