findViewById returns a null if you cast an object that the casting was not compatible with.
Such as a checkbox
ch = (CheckBox) findViewById(R.id.check);
So for whatever object you seek to fetch you must declare it like such in the XML file.
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="This checkbox is: unchecked" />
NOT
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="This checkbox is: unchecked" />
As you might leave in due to the automade boilerplate code.
It's an easy mistake to make....
Ciao
No comments:
Post a Comment