When and why should one use getResources()?

后端 未结 3 597
失恋的感觉
失恋的感觉 2021-02-03 13:45

I\'m just getting started with Android dev and playing around.

The documentation for getResources() says that it will [r]eturn a Resources instance for your applic

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-03 14:23

    A class that inherits Activity also inherits getResources(). If you have a class that is an Activity (or a derivative thereof) you have access to this method (via inheritance, a really, really basic concept in object oriented programming. If you have a class that isn't a derivative of such a class, you need to grant access to such a context for access to said resources.

    If you need more information about inheritance, polymorphism, or etc. regarding object oriented programming, I suggest referring to various websites or school curricula touching upon such issues.

提交回复
热议问题