Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting LayoutInflater using Context

Tags:

android

Is there any difference between these two?

  1. inflater = (LayoutInflater) LayoutInflater.from(context);
  2. inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
like image 683
Eugene Avatar asked Oct 05 '22 13:10

Eugene


1 Answers

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.

like image 159
CommonsWare Avatar answered Oct 10 '22 03:10

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!