Reputation: 117
I'm running into a strange problem.
I have a CheckBox defined in a resource file:
When trying to see if the checkbox is checked or not, I use the following code:
CheckBox cb1 = (CheckBox)findViewById(R.id.check1);
when I execute the following:
if (cb1.isChecked()) { }
I get a null exception error. I cannot figure out why this is happening.
Thanks for any help.
Upvotes: 0
Views: 357
Reputation: 1317
cb1
is null, which means that findViewById()
couldn't find the view whose ID you specified. Do you have a CheckBox
in your layout file with android:id="@+id/check1"
?
Upvotes: 1