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