Android:button Property

Source: Internet
Author: User

Common Properties in code:

Button bt=new buttion (context context);

Setclickable (Boolean clickable)

Sets whether the button allows clicks.

Clickable=true: Allow click

Clickable=false: No click

Setbackgroundresource (int resid)

Sets the background color from the resource file.

Resid: Resource XML file ID.

The default background for the button is: Android. R.drawable.btn_default

SetText (charsequence text) Sets the button to display text.
SetTextColor (int color)

Sets the color of the button display text.

Color can use system color constants, such as Color.Black.

Setonclicklistener (Onclicklistener L) Set Button click events

Common attributes in XML:

Android:layout_width= ""---control width

Android:layout_height= ""---control high

Android:layout_weight= ""---control weights

Android:text= ""---the text content on the control

android:onclick= "DoClick"---the method that is called when this control is clicked---method name is: DoClick

Android:drawabletop= ""---place the picture on the button component

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.