Tuesday, July 6, 2010

Custom Components

In the book Android 2- Application Develpment there is a section in chapter 4 that describes how to create compound components. He shows the basics of creating one, but doesn't actually show you how to use it. Unfortunately his example code only shows him overwriting one of the two constructors.

Constructor(Context context){
super(Context context);
}

Constructor(Context context, AttributeSet attrs){
super(Context context, AttributeSet attrs);
}

It is important that you overwrite both in my opinion, but especially the second. If you don't, your application won't be able to set the layout from your xml file attributes. Goes to show how important it is to correctly overwrite the constructors.

No comments:

Post a Comment