There is a way to get layoutInflater:
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
and
Actually I think that the getLayoutInflater()
- Method of Activity is a convenience - method.
Remember that Activity
subclasses Context
, so all of the Methods available within Context
are also available in the Activity
Class.
Internally there will be a call to LayoutInflater.fromContext()
or context.getSystemService()
, so I would stick to context.getSystemService
both to avoid the unnecessary method call as well to clarify that I am making a call to a system service.