Android Custom user Controls simple example (ii)

Source: Internet
Author: User

It is not very convenient for other people to use controls that are completely custom-built, because we often need to see the effects of the controls placed on the XML interface and adjust the layout based on the effects, which requires a more standard control-making process:

  1. Our custom controls, like other controls, should be written as a class, and the properties of this class are self-determined.
  2. We want to create a attrs.xml file in the Res/values directory and add the definition of the control's properties to this file.
  3. Use AttributeSet to complete the constructor of the control class, and in the constructor, connect the variables in the custom control class to the properties in the Attrs.xml.
  4. Use these already connected property variables in your custom control class.
  5. Define the custom control class to the XML file used in the layout.
  6. This custom control class object is generated and used in the interface.

This blog will refine the last piece of control authoring so that it can become a standardized custom control.

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.