Android API Chinese Document Button

Source: Internet
Author: User

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

 
 
  1. public class Button extends TextView  
  2. java.lang.Object  
  3. android.view.View  
  4. android.widget.TextView  
  5. android.widget.Button 

Known direct subclass

 
 
  1. CompoundButton 

Known indirect subclass

 
 
  1. CheckBox  
  2. RadioButton  
  3. 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!

Related Article

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.