I have two classes (ClassA and ClassB) that should be ListFragment. These two classes share behavior,thus I created an abstract class(AbstractClass). So AbstractClass inherit from ListFragment. So far I have my ClassA and ClassB that inherit from my AbstractClass which inherit from ListFragment. The problem comes when I need another ClassC that should be a Fragment(not ListFragment) but also it need the behavior from the AbstractClass, but I cant inherit from it because ClassC should be just Fragment and my abstractClass is ListFragment. I would like to have my ClassA,ClassB and ClassC inherit from my AbstractClass but being ClassA,ClassB Listfragment and ClassC just Fragment. Im sure should be some design pattern in Java or good practice to solve this.
I know that java does not allow multiple inheritance.
Many thanks
Can you extract common functionality to some helper class? Use composition instead of inheritance
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With