Difference between getString() and getResources.getString()

前端 未结 3 1353
闹比i
闹比i 2020-12-01 05:57

I noticed that the Activity class has two different methods to get a String resource. This is possible by using:

  • getString(int resId)

相关标签:
3条回答
  • 2020-12-01 06:33

    In Fragments you can use also getString() instead of getActivity().getString()

    0 讨论(0)
  • 2020-12-01 06:37

    They are the same method, nothing special about them.

    0 讨论(0)
  • 2020-12-01 06:48

    They are the same as Activity.getString(int) does exactly that:

     public final String getString(int resId) {
         return getResources().getString(resId);
     }
    
    0 讨论(0)
提交回复
热议问题