Android使用自定义View时:Error inflating class错误的原因。

当在布局文件里使用自定义的View的时候,出现Error inflating class错误的原因:

1、没有定义inflate需要的默认构造函数;

  eg:自定义View为TestView,需要定义TestView(Context context),TestView(Context context,AttributeSet set);

2、这是个内部类,需要声明为static才能inflate;

转载于:https://www.cnblogs.com/lkzero/p/error_inflate_class.html

猜你喜欢

转载自blog.csdn.net/weixin_33901926/article/details/93852707
今日推荐