Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
要在活动中使用片段,我们需要Fragment在该活动中进行扩展。但是我的活动已经扩展了另一个类,而 java 不能扩展 2 个类。那么如何在已经扩展了另一个类的活动中使用片段呢?
Fragment
在 C++ 中尝试了多重继承(多个父类)并带来了一些有趣的挑战,因此 Java 设计者决定尝试“接口”。
对于您的实际问题,在您自己的对象中有一个 Fragment 对象并调用您需要的方法。