Eugene
Eugene

Reputation: 60184

Getting LayoutInflater using Context

Is there any difference between these two?

  1. inflater = (LayoutInflater) LayoutInflater.from(context);
  2. inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

Upvotes: 5

Views: 303

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006614

Not at the present time, as you can see by examining the LayoutInflater source code. from() will throw an Exception rather than returning null, but otherwise they are identical.

Personally, I use getLayoutInflater() most times.

Upvotes: 4

Related Questions