There is a way to get layoutInflater:
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
and another way is:
LayoutInflater inflater = LayoutInflater.from(context);
a third one (when I am in an Activity) is:
LayoutInflater inflater = getLayoutInflater();
So what is the difference between them?
Note that when I sent the third inflater to my adapter, my application worked. But when I sent the context and created the inflater via the second way, it didn't!
There is not much of a difference between them.
As doc says public abstract Object getSystemService (String name)
A LayoutInflater for inflating layout resources in this context.
And for the public static LayoutInflater from (Context context)
Obtains the LayoutInflater from the given context.
You can check this thread Is there any difference between getLayoutInflater() and .getSystemService(Context.LAYOUT_INFLATER_SERVICE)