Search code examples
androidxmllayout-inflaterandroid-inflate

Is there a difference between LayoutInflater.from(context) and context.getLayoutInflater()?


My question is basically in the title but I am curious if there is a difference between context.getLayoutInflater() and LayoutInflater.from(context). For example:

View contentView = getActivity().getLayoutInflater().inflate(R.layout.some_layout, null);

and

View contentView = LayoutInflater.from(getActivity()).inflate(R.layout.some_layout, null);


Solution

  • No, they do the same thing. I see the from version used more these days, but they will do the same thing.