Android Runtime exception: Binary XML file Line #: Error inflating class

Source: Internet
Author: User

When customizing view, the long time finally got it done.

When inheriting view, you want to implement all of its constructors.

Such as:

1  Public classHongdianextendsView {2     floatX=40;3     floatY=50;4Paint p =NewPaint ();5The construct to implement6      PublicHongdian (Context context) {7         Super(context);8     }9The constructor to implementTen      PublicHongdian (Context context, @Nullable AttributeSet attrs) { One         Super(context, attrs); A     } -The constructor to implement -      PublicHongdian (context context, @Nullable AttributeSet attrs,intdefstyleattr) { the         Super(context, attrs, defstyleattr); -     } -The constructor to implement -      PublicHongdian (context context, @Nullable AttributeSet attrs,intDefstyleattr,intdefstyleres) { +         Super(context, Attrs, defstyleattr, defstyleres); -     } +  A @Override at     protected voidOnDraw (canvas canvas) { -         Super. OnDraw (canvas); - P.setcolor (color.black); -Canvas.drawcircle (x,y,15, p); -     } -  in @Override -      Public Booleanontouchevent (Motionevent event) { tox =event.getx (); +y =event.gety (); -          This. Invalidate (); the         return true; *     } $}

Android Runtime exception: Binary XML file Line #: Error inflating class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.