Reputation: 6302
I want to create a generic super class called Vista that extends android Activity, and then create all my activities extending my class Vista (thus to inherit all my common methods in all my activities). But in the project I have some FragmentActivity classes and I can't extend these from the class Vista.
Any solution? Can i change my FragmentActivity in a simile Activity and use android.app.fragment with TabHost inside, instead of android.support.v4.fragment because I am develop for android 4+ ?
Upvotes: 2
Views: 2324
Reputation: 23001
You need to make the Vista class a standalone helper class. Then create an ActivityVista class that extends Activity and includes an instance of the Vista helper class as a private member. And also create a FragmentActivityVista class that extends FragmentActivity and includes an instance of the Vista helper class.
The ActivityVista and FragmentActivityVista classes will have to have a bunch of forwarding functions that call through to the Vista helper class, but they at least won't have to duplicate the full functionality.
Upvotes: 3
Reputation: 8224
You have 2 ways :
Best wishes.
Upvotes: 1