1. Use of common controls:
Textviewbuttonedittextimageview1.TextView
<textview android:id= "@+id/text_view" android:layout_width= "match_parent" android:layout_height = "Wrap_content" android:text= "This is TextView"/>
ANDROID:LAYOUT_WIDTH Specifies the width of the control
Android:layout_height Specifies the height of the control
All controls in Android have these two properties, with selectable values of three match_parent, Fill_parent, and wrap_content (size consistent with content)
android:gravity= "Center" text alignment
Android:textsize= "24SP" Font size
Android:textcolor= "#00ff00" Font Color
2.Button
<button android:id= "@+id/button" android:layout_width= "match_parent" android:layout_height= " Wrap_content " android:text=" button "/>
Register Listener
1.//Anonymous class methods
Button = (button) Findviewbyid (R.id.button); Button.setonclicklistener (New Onclicklistener () { @Override public void OnClick (View v) {//Add logic here}});
2.//Implementation Interface Onclicklistener
public class Mainactivity extends Activity implements Onclicklistener {
Private button button;
@Override protected void onCreate (Bundle savedinstancestate) {
Setcontentview (R.layout.activity_main);
Button.setonclicklistener (this);}
@Override public void OnClick (View v) {
Switch (V.getid ()) {case r.id.button://adds logic here
break; Default
Break }
}
}
3.EditText
Controls that allow you to enter and edit content in a control
<edittext android:id= "@+id/edit_text" android:layout_width= "match_parent" android:layout_ height= "Wrap_content"
Suggestive text
android:hint= "Type something Here"/>
/>
The Android:maxlines property can specify the maximum number of rows to display
Get input from EditText
Gets the EditText object that calls the EditText object's GetText (). ToString () method ImageView Controls for displaying pictures android:src property specifies a picture resource
<imageview android:id= "@+id/image_view" android:layout_width= "wrap_content" android:layout_ height= "Wrap_content" android:src= "@drawable/ic_launcher" />
Dynamically change the picture in ImageView by code
Imageview.setimageresource (R.drawable.jelly_bean);
ProgressBar
ProgressBar is used to display a progress bar on the interface, indicating that our program is loading some data.
ANDROID04-UI01 Common Controls