Error inflating class wrong reason: custom View Android use.

When using a custom View in the layout file because an error occurs Error inflating class:

1, there is no defined default constructor needs inflate;

  eg: Custom View as TestView, need to define TestView (Context context), TestView (Context context, AttributeSet set);

2, this is an internal class, it should be declared static to inflate;

Reproduced in: https: //www.cnblogs.com/lkzero/p/error_inflate_class.html

Guess you like

Origin blog.csdn.net/weixin_33901926/article/details/93852707