As a beginning Android programmer who is not a beginning programmer, I am alarmed by the amount of time it took me until I realized that the crash was resulting from omitting to use the constructor taking AttributeSet as a second parameter and writing instead the following code for a custom view defined in an XML layout.
////////MyView.java////////
public class MyView extends View {
public SimpleView(Context context) {
super(context);
}
...
}
My question is this: What could I have done (in Eclipse, the ADT variant) to be able to determine this error quickly? I look rather carefully at lint messages and was hoping that that habit would spare me spending hours for a single error.
The manual does of course clearly state that custom views defined in an XML layout should use the (Context, AttributeSet) variant of the View constructor, but it is hopeless to program at any level while recalling with precision every last detail in the reference pages.
There should be the following error in the Graphical Layout:
But I agree that a compile-time error would be better…