We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
try { //public View createView // (View parent, final String name, @NonNull Context context, @NonNull AttributeSet attrs) if (sCreateViewMethod == null) { Method methodOnCreateView = delegate.getClass().getMethod("createView", sCreateViewSignature); sCreateViewMethod = methodOnCreateView; } Object object = sCreateViewMethod.invoke(delegate, parent, name, context, attrs); view = (View) object; } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); }
这里的代码为什么用发射创建而不是用 直接调用delegate.createView 呢?如下
view = delegate.createView(parent, name, context, attrs);
The text was updated successfully, but these errors were encountered:
我猜测是作者怕哪个版本的createView方法变成private,就不能调用了,用反射保险一些 不知道猜的对不对,请HongYang兄解惑一下:)
Sorry, something went wrong.
搞不懂为什么要实现createView这个部分,应该只需要解析attrs就好了。createView还是由父类完成就好了? @OverRide public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { View view = super.onCreateView(parent, name, context, attrs); List skinAttrList = SkinAttrSupport.getSkinAttrs(attrs, context); if (skinAttrList.isEmpty()) { return view; } if (view == null) { view = createViewFromTag(context, name, attrs); } injectSkin(view, skinAttrList); return view;
}
No branches or pull requests
这里的代码为什么用发射创建而不是用 直接调用delegate.createView 呢?如下
The text was updated successfully, but these errors were encountered: