Domanda

I have Activity class, ListActivity class, TabActivity class. I want expand these classes using the same functionality. For example add method toDoSomething() into each of them. It is impossible to do using мultiple inheritance in Java.

Could you please tell me desing pattern or other solution to resolve this issue without copy-paste

Thanks!

È stato utile?

Soluzione

You can do less copy-paste if you define your own class DoSomethingHelper with doSomething() method (probably doSomething(Activity activity)), then refer to it from all of your activities as needed. I don't know of any better solution.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top