Rohit k
Rohit k

Reputation: 23

how to extends two class Android activity?

I want to-->

class mainactivity extends ListActivity,MapActivity{ }

It's possible???

class mainactivity extends Any java class1,Any java Class2{ }

anyone possible??

Upvotes: 4

Views: 15953

Answers (4)

Android Killer
Android Killer

Reputation: 18489

No it's not possible because you can not extend more than one class but you can implement more than one interface which is not of any use here.

Upvotes: 3

Jerry Abraham
Jerry Abraham

Reputation: 1039

Java does not support multiple inheritance, more than one class can not be extended but there is solution , but in your case i think you can use like this:

  class MapActivity extends Service{
   ...
  }

 class mainactivity extends ListActivity{

  MapActivity mapActivity= new MapActivity();
 }

Upvotes: 2

mathlearner
mathlearner

Reputation: 7639

no its not possible because in core java a class can only inherit one class . In c++ its possible to inherit more than one class. So thats why its not possible

Upvotes: 2

A.Quiroga
A.Quiroga

Reputation: 5722

you can't . java doesn't let that type of polymorphism . You must use implements for interfaces .

Read this

Upvotes: 7

Related Questions