Android APIThe Chinese document "Button" is the content to be introduced in this article, mainly for understanding and learning.Android APIDocument Content, detailsAndroid APIFor more information about this document, see this article.
I. Android API Structure
- public class Button extends TextView
- java.lang.Object
- android.view.View
- android.widget.TextView
- android.widget.Button
Known direct subclass
- CompoundButton
Known indirect subclass
- CheckBox
- RadioButton
- ToggleButton
Ii. Android API Overview
The Android API represents a button component. You can perform an action by pressing the button or clicking the button. The following is a typical application of a button in an activity:
Then, you can specify a method through the android: onClick attribute of the button in the xml layout, instead of setting OnClickListener for the button in the activity. For example:
Now, when you click the button, the Android system calls the selfDestruct (View) method of activity. For proper execution, this method must be public and only accept one View parameter. For example:
3. Android API button style
By default, the style of each button is the background of the system button. different devices and platform versions have different button styles. If you are not satisfied with the default button style and want to customize it to suit your application design, you can replace the background image of the button with the state list drawable. A Status List drawable is a drawable resource defined in XML. It changes its image based on the status of the current button. Once you define a status list drawable in XML, you can apply it to your android: background attribute. For more information and examples, see State List Drawable.
For an example of implementing a button, see Form Stuff tutorial.
Summary:Android APIThe content of the Button in the Chinese document is complete.Android APIContent learning is helpful to you!