Tiago Oliveira
Tiago Oliveira

Reputation: 1602

CheckBox onCheckedListener not working DataBinding

Im trying to listen when the checkbox is checked or not.

Problem

onCheckedListener is never called

What have i tried

XML

<CheckBox
   android:onCheckedChanged="@{(v, checked) -> handler.onCheckedChanged(checked)}"
   ...
 />

<variable
    name="handler"
    type="com.example.tiago.demo.Search.Adapter.Adapter"/>

Adapter.java (com.example.tiago.demo.Search.Adapter)

public void onCheckedChanged(boolean isCheck){
    Log.d("adapter","Is checked: ".concat(String.valueOf(isCheck)));
}

I read similar posts about this on forums and in here, but none of them work for me, this one is the only one that lets me compile with no problems, but when i click on the checkbox i don't get any log message.

Notes

Upvotes: 1

Views: 3687

Answers (1)

Tiago Oliveira
Tiago Oliveira

Reputation: 1602

I was able to fix my issue, i was not binding the variable silly mistake

Upvotes: 1

Related Questions