5

这两者有什么区别吗?

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

1 回答 1

4

目前还没有,正如您通过查看源代码所看到LayoutInflater那样。from()将抛出一个Exception而不是返回null,但除此之外它们是相同的。

就个人而言,我使用的getLayoutInflater()次数最多。

于 2012-12-24T13:42:09.010 回答