Cannot resolve method getActivity()

后端 未结 3 2066
猫巷女王i
猫巷女王i 2020-12-16 10:58
  • I am new to Android and learning to create fragments in Android by following this
    example: Fragment Navigation Drawer

  • The code between N

3条回答
  •  囚心锁ツ
    2020-12-16 11:06

    An Activity has no getActivity() method.
    Fragments have.

    Because getActivity() says: "return the Activity which contains me".

    And while Framents are contained in Activities, Activities themselves aren't.

提交回复
热议问题