这两者有什么区别吗?
inflater = (LayoutInflater) LayoutInflater.from(context);
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
最佳答案
目前还没有,正如您通过检查 the LayoutInflater
source code 可以看到的那样. from()
将抛出一个 Exception
而不是返回 null
,但除此之外它们是相同的。
就个人而言,我大部分时间都使用 getLayoutInflater()
。
关于android - 使用 Context 获取 LayoutInflater,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14022094/