开发者社区 问答 正文

android内部类继承Fragment为什么要用static?报错

请问一下内部类继承Fragment为什么要用static,删除static会报错。求解答。在线等!

展开
收起
爱吃鱼的程序员 2020-06-22 20:23:35 427 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    <spanstyle="font-family:Verdana,sans-serif,宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;">Fragment类含Static方法或对象publicclassOutside{publicclassFextendsFragment{}}publicclassFragment{publicstaticvoidtest(){System.out.println("testinfragment");}}简化成这样为什么可以实现呢?<imgsrc="http://static.oschina.net/uploads/space/2013/0412/172510_15F8_242175.jpg"alt=""/>那为什么这样就可以实现啊?

    2020-06-22 20:23:53
    赞同 展开评论