简体   繁体   中英

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??

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

Read this

不,这是不可能的,因为你不能扩展多个类,但你可以实现多个这里没有任何用处的接口。

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();
 }

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM