Luis Randolfo
Luis Randolfo

Reputation: 23

Is it safe to subclass basic framework classes?

I realize that future API versions will (mostly) be backwards compatible regarding methods, but can I "safely" create my own MyTextView.class that extends TextView, or will this likely break with the next major API version update?

Upvotes: 0

Views: 42

Answers (2)

Blue Nite
Blue Nite

Reputation: 118

There is nothing wrong with extending those classes. If you are really concerned about backwards compatibility you can extend App Components

These Support Library classes provide backward-compatible implementations of important, core platform features. These implementation typically extend earlier versions of the class to handle new methods and features added in more recent releases of the platform. Some of these classes are complete, static implementations of the framework APIs.

Upvotes: 0

Joe C
Joe C

Reputation: 15714

Ultimately, unless the relevant Javadoc says otherwise, subclassing a class is no more likely to cause breaking changes with an upgrade than using it in any other standard way.

Upvotes: 2

Related Questions