Space Ghost
Space Ghost

Reputation: 765

Is calling super always necessary when extending a View?

Is it always a must for extending the View?

public class MyNewView extends View{
    public MyNewView(Context context) {
        super(context);
    }
}

Upvotes: 0

Views: 70

Answers (1)

laalto
laalto

Reputation: 152887

Yes. Since View does not have a no-arg constructor *, derived classes must call superclass constructor explicitly.

* there is a package-private no-arg constructor you cannot and should not use

Upvotes: 5

Related Questions