5
这两者有什么区别吗?使用上下文获取LayoutInflater
inflater = (LayoutInflater) LayoutInflater.from(context);
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
这两者有什么区别吗?使用上下文获取LayoutInflater
inflater = (LayoutInflater) LayoutInflater.from(context);
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
不是在现在,你可以通过检查the LayoutInflater
source code看到。 from()
将抛出一个Exception
而不是返回null
,但否则它们是相同的。
我个人最多使用getLayoutInflater()
。