如何一个类可以用两种不同类型的延伸,而一个类是从外部库等是内置的 [英] How a class can extend with two different classes While one class is from a external library and other is built in

查看:133
本文介绍了如何一个类可以用两种不同类型的延伸,而一个类是从外部库等是内置的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用SherlockActionBar库在我project.And我的类扩展一个抽象类SherlockActivity

I am using SherlockActionBar library in my project.And my class is extending an abstract class SherlockActivity

public class AllAppsInfo extends SherlockActivity{}

在这其间我想延长我的AllAppsInfo与FragmentActivity作为well.Which不允许由于Java的多重继承的疏忽造成的。

In mean while i want to extend my AllAppsInfo with FragmentActivity as well.Which is not allowed due to negligence of multiple inheritance in java.

我已经做了一些搜索,组成了解决方案,但如何在这种情况下使用呢?无论是我可以使抽象的大侦探类的接口也同样可以用片段Activity类完成

I have done some search, composition is the solution but how to use it in this Scenario? Neither i can make abstract Sherlock class a interface nor same be done with Fragment Activity class .

推荐答案

我已经用我的扩展类解决了这个问题的 SherlockFragmentActivity

I have solved this issue by extending my class with SherlockFragmentActivity

public class AllAppsInfo extends SherlockFragmentActivity{}

这篇关于如何一个类可以用两种不同类型的延伸,而一个类是从外部库等是内置的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆