Is there any difference between getLayoutInflater() and .getSystemService(Context.LAYOUT_INFLATER_SERVICE)

前端 未结 4 705
无人共我
无人共我 2020-12-08 20:09

Simple \"No\" answer will calm me. If there is any difference then what it is?

4条回答
  •  醉话见心
    2020-12-08 20:14

    This is how you define a LayoutInflater.

    LayoutInflater inflater = (LayoutInflater)context.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
    

    And getLayoutInflater() just gives "quick access to the LayoutInflater instance that the window retrieved from its Context" (from the documentation) by returning the LayoutInflater.

    Similarly, getSystemService(Context.LAYOUT_INFLATER_SERVICE) is used to retrieve a LayoutInflater for inflating layout resources in this context.

    So, actually there is NO difference between the two.

    Source : Documentation

提交回复
热议问题