Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 269
Lord_JABA Avatar asked Aug 26 '12 17:08

Lord_JABA


1 Answers

No

As long as the Activity or Window that calls getLayoutInflater() has the same Context that would call getSystemService(), there is no difference.


Proof You can trace the LayoutInflater returned by getLayoutInflater() to LayoutInflater.from() and you can see this is just a shortcut for getSystemService() from the source code:

public static LayoutInflater from(Context context) {     LayoutInflater LayoutInflater =             (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);     if (LayoutInflater == null) {         throw new AssertionError("LayoutInflater not found.");     }     return LayoutInflater; } 
like image 125
Sam Avatar answered Oct 15 '22 15:10

Sam