2012-12-24 23 views
5

这两者有什么区别吗?使用上下文获取LayoutInflater

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

回答

4

不是在现在,你可以通过检查the LayoutInflater source code看到。 from()将抛出一个Exception而不是返回null,但否则它们是相同的。

我个人最多使用getLayoutInflater()