Android custom control 1 -- Introduction to custom control, android1 --
Basic Introduction to Android controls
Android provides many widgets, such
TextView and EditText;
Button control Button and ImageButton
Status switch button ToggleButton
Radio check buttons RadioButton and RadioGroup
Single choice button and check button CheckBox
ImageView
Clock controls AnalogClock and DigitalClock
The progress bar and the date and time selection controls DatePicker and TimePicker.
TextView and EditText
The TextView control inherits from the View class. The TextView control displays text content to users and allows users to edit texts selectively. TextView cannot be edited.
The EditText control is inherited from TextView. The biggest difference between EditText and TextView is that EditText can be edited.
Button control Button and ImageButton
The usage of the Button control inherited from the TextView Button class is relatively simple. It mainly sets the View. OnClickListener. listener for the Button control and writes the processing code for pressing the Button in the implementation code of the listener.
The ImageButton control is inherited from the ImageView. The biggest difference between ImageButton and Button is that ImageButton does not have the text attribute, so images rather than text are displayed in buttons. You can use the android: src attribute or setImageResurce (int) method to set the display image in the ImageButton control.
Status switch button ToggleButton
The ToggleButton control is inherited from the Button. The ToggleButton status can only be selected or not selected, and different display text needs to be set for different states. In addition to inheriting some attributes and methods of the parent class, ToggleButton also has some own ToggleButton attributes.
Single button and check button CheckBox and RadioButton
Both CheckBox and RadioButton have only the selected and unselected statuses, and can be set through the checked attribute.
The difference is that RadioButton is a single-choice button, which must be compiled into a RadioGroup. Only one button in a RadioGroup can be selected at the same time.
Both CheckBox and RadioButton inherit from CompoundButton and inherit some members.
ImageView
The ImageView control is used to display images. The image source can be either the resource file id, Drawable object, Bitmap object, or Content Provider Uri.
Clock controls AnalogClock and DigitalClock
The AnalogClock inherits from the ViewAnalogClock control to display a simulated clock. Only the hour and minute hands are displayed.
DigeitalClock inherits from TextView. The DigetalClock display digital clock can be accurate to seconds. The clock control is relatively simple. You only need to declare the control in the layout file.
Date and Time Selection controls DatePicker and TimePicker
DatePicker inherits the date selection control of the FrameLayout class. It provides users with date data including year, month, and day, and allows users to select it. If you want to capture the event of data in the user's date Selection control, you need to add the onDateChangedListener listener for the DatePicker.
TimePicker also inherits from the FrameLayout class. The Time Selection Control shows users that the time in a day can be in the 24-hour format, and can be in the AM/PM format. If you want to capture the event of the user's modification time data, you need to add the OnTimeChangedListener listener for the TimePicker.
URL: http://www.cnblogs.com/wuyudong/p/5912506.html.
However, these controls cannot meet all our requirements. Sometimes we have to define controls to meet our requirements.
Custom controls can be divided into three types:
1. Combine existing controls for implementation
2. Fully custom controls (inheriting View and ViewGroup)
3. inherit the existing control implementation (extend existing functions)