80,351
社区成员
发帖
与我相关
我的任务
分享
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
LayoutInflaterCompat.setFactory2(LayoutInflater.from(this), new LayoutInflater.Factory2() {
//'这个方法是Factory接口里面的,因为Factory2是继承Factory的'
@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
return null;
}
//'这个方法是Factory2里面定义的方法'
@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
Log.e(TAG, "parent:" + parent + ",name = " + name);
int n = attrs.getAttributeCount();
for (int i = 0; i < n; i++) {
Log.e(TAG, attrs.getAttributeName(i) + " , " + attrs.getAttributeValue(i));
}
return null;
}
});
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test1);
}