Android Custom Controls introduction to custom controls

Source: Internet
Author: User

Basic Introduction to Android controls

Android itself provides a number of controls, such as those we use
Text controls TextView and EditText;
Button control buttons and ImageButton
Status Switch Button ToggleButton
Radio Check button RadioButton and Radiogroup
radio button and check button checkbox
Picture Control ImageView
Clock controls AnalogClock and DigitalClock
Progress bar ProgressBar and date and time selection controls DatePicker and Timepicker, and so on.

Text Controls TextView and EditText

The TextView control inherits from the View class. The function of the TextView control is to display text content to the user while optionally allowing the user to edit the text. Where TextView is not allowed to edit.
The EditText control EditText control inherits from TextView. The biggest difference between EditText and TextView is that EditText can be edited.

Button control buttons and ImageButton

The simple use of the button control to inherit from the TextView class button is primarily to set the View.onclicklistener. Listener for the button control and to write the handling code of the button press event in the listener's implementation code.
The ImageButton control ImageButton inherits from ImageView. The biggest difference between a ImageButton and a button is that ImageButton does not have a Text property that displays a picture instead of a literal. Setting the display picture in the ImageButton control can be done by using the Android:src property or by using the Setimageresurce (int) method.

Status Switch Button ToggleButton

The ToggleButton control is inherited from the Button. The status of ToggleButton can only be checked and unchecked, and different display text needs to be set for different states. In addition to some properties and methods that inherit from the parent class, ToggleButton also has some of its own ToggleButton properties.

radio button and check button checkbox and RadioButton

Checkboxes and RadioButton are only checked and unchecked in two states and can be set by the Checked property.
The difference is that RadioButton is a radio button that needs to be compiled into a radiogroup at the same time a radiogroup can only have one button selected.
Both the checkbox and the RadioButton inherit some members from the Compoundbutton.

Picture Control ImageView

The ImageView control is responsible for displaying the picture, which can be either the ID of the resource file, the Drawable object or the Bitmap object, or the URI of the Content Provider.
Clock controls AnalogClock and DigitalClock
AnalogClock inherits from Viewanalogclock control display analog clock only show hour and minute hand
Digeitalclock inherits from TextView. The Digetalclock shows the digital clock to be accurate to seconds. The clock control is simple to simply declare the control in the layout file.

Date and time selection controls DatePicker and Timepicker

DatePicker the primary function of inheriting from the Framelayout class date selection control is to provide the user with date data that contains the year, month, and day and allow the user to select it. If you want to capture an event in which the user modifies data in a date selection control, you need to add a Ondatechangedlistener listener for DatePicker.
Timepicker also inherits from the Framelayout class. The time selection control shows the user that the time of day can be a 24-hour system that can be AM/PM and allows the user to make a selection. If you want to capture events for user-modified time data, you need to add a Ontimechangedlistener listener for Timepicker

This article address: http://www.cnblogs.com/wuyudong/p/5912506.html, reprint please indicate source address.

But these controls do not meet all of our requirements. Sometimes we have to define our own controls to meet our requirements.

Custom controls can be categorized into three main types:

1. Combining existing control implementations

2. Fully customizable controls (inherit view, ViewGroup)

3. Inherit existing control implementations (extend existing functionality)

Android Custom Controls introduction to custom controls

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.