Reputation: 11
Im trying to inherit from multiple classes, I have been told I should use interface, but the problem is that these are predefined classes in java, such as example activity class and Fragment class
Help would be appreciated!!
Upvotes: 1
Views: 122
Reputation: 6554
You could inherit from multiple classes in C++ and not Java. You need to rethink your strategy.
Upvotes: 1
Reputation: 5624
You can only extend from one class in Java. In your case, FragmentActivity
seems to be the right choice. Otherwise interfaces are the way to go. Fragments and Activities are different creatures in the android lifecycle and can't be treated equal.
Note that you can have instances of however many different classes in your own custom class though. But that class doesn't have to extend anything.
Upvotes: 1
Reputation: 24998
It seems like a contradiction in design, doesn't it ? An Activity
may contain Fragment
s. If you make something both an Activity
and Fragment
, what are you trying to do ? =)
No, you can never inherit from two classes in Java.
Upvotes: 1