【发布时间】:2012-06-02 08:24:15
【问题描述】:
我浏览了一些教程,在 Android Doc 中,它说在实例化 LayoutInflater 时不要直接访问它。来自谷歌文档的示例:
LayoutInflater inflater = (LayoutInflater)context.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
我经历的教程是这个:
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
所以我真的不明白除了明显不同的代码之外还有什么区别。任何解释都非常感谢。我认为 Android Doc 应该是我们遵循的那个,但我不确定它是否会有所作为。
【问题讨论】: