[Solved] Android Checkbox getchecked (CompoundButton.OnCheckedChangeListener (without button click event))


You are fetching your CheckBox with

findViewById(R.id.checkbox); 

when in the xml, the id is

android:id="@+id/checkBox"

The id is case sensitive so check your capitalization. Basically your code is fetching a view by ID and not finding it. Therefore your cb object is set to null and you throw a nullpointer here

cb.setOnCheckedChangeListener(this);

0

solved Android Checkbox getchecked (CompoundButton.OnCheckedChangeListener (without button click event))