【发布时间】:2017-01-08 05:52:34
【问题描述】:
有两个公共接口:
LayoutInflater.Factory 和 LayoutInflater.Factory2 在 android sdk 中,但官方文档不能说有关此接口的有用信息,即使是 LayoutInflater 文档。
据我了解,如果设置了Factory2,则将使用它,否则将使用Factory:
View view;
if (mFactory2 != null) {
view = mFactory2.onCreateView(parent, name, context, attrs);
} else if (mFactory != null) {
view = mFactory.onCreateView(name, context, attrs);
} else {
view = null;
}
setFactory2() 也有非常简洁的文档:
/**
* Like {@link #setFactory}, but allows you to set a {@link Factory2}
* interface.
*/
public void setFactory2(Factory2 factory) {
如果我想将自定义工厂设置为LayoutInflater,我应该使用哪个工厂?
它们有什么区别?
【问题讨论】:
标签: java android layout-inflater