android – 使用Context获取LayoutInflater

前端之家收集整理的这篇文章主要介绍了android – 使用Context获取LayoutInflater前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

这两者有什么区别吗?

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

最佳答案
目前还没有,正如你可以通过检查the LayoutInflater source code看到的那样.来自()将抛出异常而不是返回null,但是否则它们是相同的.

就个人而言,我大多数时候都使用getLayoutInflater().

原文链接:https://www.f2er.com/android/430757.html

猜你在找的Android相关文章