I have a two classes with the same content, but first class is for android version <honeycomb
and extends support library for fragments. Second class for version higher than honeycomb
and extends native sdk library. Is it possible to have only one class file but somehow extend it for both?
You can't, but both of them can implement the same Interface, and the class that wants to use these 2 classes will just have to use that interface (This is called the Strategy
Pattern). Depending on the version of the OS, you'll return a class or the other when asking for that interface ( Factory
Pattern).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.