Search code examples
javaandroidandroid-actionbarclass-extensions

What class should I extend, AcionBar or ActionBarImpl?


I feel this is a basic question wiht some trick.
I want to extend the functionality of ActionBar, upon looking up the ActionBar code it turns out ActionBar is an abstract class and the real instantiated class is ActionBarImpl.
This pattern of having an abstract and a Impl for implementation is widely used in android source code.
The developers site does not dwell in details, but always describes the abstract class as if it was the implemented class.
I see that from the java language strict point of view I should extend ActionBarImpl, otherwise I will not be able to call super methods, but I have never seen an example out there extending the <class>Impl classes.
Help.


Solution

  • The only difference between the abstract and implementation in this case is likely to be the abstract method(s). If the default behavior provided by the implementation class is acceptable, I'd say extend that and override the other methods you need.

    If the abstract method behavior you want means you can't use the implementation at all, then extend the abstract class.