如何使用片段中已经扩展了另一个类的活动? [英] How to use fragments in an activity which already extends another class?

查看:95
本文介绍了如何使用片段中已经扩展了另一个类的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在活动中使用的片段,我们需要在活动延长片段。但是,我的活动已经扩展了另一个类,和java不能延长2班。因此,如何使用已经扩展了另一个类的活动里面的片段?

To use fragments in an activity, we need to extend Fragment in that activity. But my activity already extends another class, and java cannot extend 2 classes. So how to use fragments inside an activity that already extends another class?

推荐答案

多重继承(多个父类)的尝试在C ++中,给了一些有趣的挑战,所以Java的设计者决定尝试界面代替。

Multiple inheritance (more than one parent class) was tried in C++ and gave some interesting challenges, so the Java designers decided to try "interfaces" instead.

有关实际问题,有自己的对象内部Fragment对象,并调用需要的方法。

For your actual problem, have a Fragment object inside your own object and invoke the methods you need.

这篇关于如何使用片段中已经扩展了另一个类的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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