Steps to implement Android custom controls (i)

Source: Internet
Author: User

This afternoon, the study of the Android custom control how to achieve, is a little bit of a look, now summed up, as a deeper memory, perhaps for those who have just started to learn Android will be a little help

Here are the steps I've summed up:

1. First, to create a attrs XML file to store the properties of the custom control, create an XML file, then use <declare-styeable> to declare the name of the control, and then use the <attr> The label implements the name of the property and the corresponding type.

2. Create the appropriate class, inherit the control class that you want to customize, and then implement the appropriate constructor method, define the variables associated with the property and the corresponding get and set methods, and define the function functions that belong to your own implementation.

3. Then direct reference in the activity through the package name is OK.

This is the general step of customizing the control, and when I have finished my project, the complete code is pasted out for everyone's reference.

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.