1. Development of custom components

Source: Internet
Author: User

I. Custom Component Classification

Customized component: inherits the view and adds more attributes and events. Horizontal scaling

Compound component:

Inherit viewgroup and assemble multiple simple controls into one composite control by layout. Horizontal scaling

 

Ii. Define component steps

1. Select an inheritance class (it must be a subclass of view or view ).

Class 2 initialization: Initial Value Setting of new property attributes.

3. overload method:

Layout and rendering ondraw (), onmeasure ()

Event (Custom Event) onkeyevent ()... listener/overload Function

Principle]

For this project only, you can use inner class;

If you are planning to release it commercially, you need to use a separate class file;

If you plan to release the product commercially, do not use the XML layout file instead of dynamic code generation;

 

3. Use Components

[Internal class]

<View

Class = "com. Android. notepad. noteeditor $ myedittext"

Id = "@ + ID/Note"

Android: layout_width = "fill_parent"

Android: layout_height = "fill_parent"

Android: Background = "@ Android: drawable/empty"

Android: padding = "10dip"

Android: scrollbars = "vertical"

Android: fadingedge = "vertical"/>

 

[Non-internal class]

<Com. Android. notepad. myedittext

Id = "@ + ID/Note"

.../>

 

1. Development of custom components

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.