Android 2.2 R1 API Chinese Document Series (12) -- button

Source: Internet
Author: User

 

Preface

As of this article, 12 Android APIs have been translated, two of which are provided by another member of the translation group. Although the translation workload is large and difficult, it is of great help to both yourself and others. If there is only one article, there are not too few, but more than 10 articles are not too much, once again appeal to everyone's enthusiastic participation in Android API Chinese translation, my mailbox over140@gmail.com.

Statement

You are welcome to repost, but please keep the original source of the article :)

Blog: http://www.cnblogs.com

Farmer's uncle: http://www.cnblogs.com/over140/

 

Body

I. 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. Overview

    

Represents a button part. 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. 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.

 

 

Iv. xml attributes

See the XML attributes of buttons, textview, and view.

 

5. Download

Http://download.csdn.net/source/2739376 (csdn)

 

Vi. Series

Android 2.2 API Chinese Document Series (1) -- textview

Android 2.2 API Chinese Document Series (2) -- edittext

Android 2.2 API Chinese Document Series (3) -- accessibilityservice

Android 2.2 API Chinese Document Series (4) -- manifest

Android 2.2 API Chinese Document Series (5) -- View

Android 2.2 API Chinese Document Series (6) -- imageview

Android 2.2 API Chinese Document Series (7) -- imagebutton

Android 2.2 API Chinese Document Series (8) -- quickcontactbadge

Android 2.2 API Chinese Document Series (9) -- zoombutton

Android 2.2 R1 API Chinese Document Series (10) -- checkbox

Android 2.2 R1 API Chinese Document Series (11) -- radiobutton

 

End

Take Chinese online materials for learning and feed them online for others to learn.

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.