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?
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.
For your actual problem, have a Fragment object inside your own object and invoke the methods you need.
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.