In this tutorial you will learn about the Android UI Controls/Widgets and its application with practical example.
As we discussed in Basic Building Block Page that View are drawn on screen. View occupies rectangle area on screen.View is a BaseClass for widgets.
There are lot off UI Controller/Widgets provided by Android ,such as Button,TextView, EditText , Checkbox, DatePicker, TimePicker, ProgressBar etc. These all allow you to build GUI for Android App.
- Button: It’s an User Interface Element from that user can tap and perform Action. To display a button on screen you have to add it on layout xml file of Activity.
1 2 3 4 5 |
<Button android:id="@+id/btn_id" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Button" /> |
2. TextView : It’s an user interface element which display text to user. Following code sample will help you to display TextView on Screen.
1 2 3 4 5 |
<TextView android:id="@+id/tv_id" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Hello World" /> |
- EditText : Its’s an UI element which is used for enter and modify text . Using below code you can display EditText Widgets.
1 2 3 4 5 6 |
<EditText android:id="@+id/plain_text_input" android:layout_height="wrap_content" android:layout_width="match_parent" android:text="Enter Detail" /> |
4.CheckBox : Checkbox is UI element which allow user to select multiple options . Using below code you can display CheckBox.
1 2 3 4 5 |
<CheckBox android:id="@+id/checkbox_cheese" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="AA" android:onClick="onCheckboxClicked"/> |
5.DatePicker : The Datepicker allow users to select a date of the day.
6.TimePicker : The TimePicker view allow users to select a time of the day.
7.ProgressBar: This view is useful when you want to display that some task is going on, It gives visual feedback.
8.RadioButton : it has two state either checked or unchecked, when it is checked ,the user can press it to unchecked it. Radio buttons are mainly used in RadioGroup. In Radio group when you checked any radio button so rest automatically becomes unchecked.
- ToggleButton : ToggleButton is a button which have two condition i.e. On/Off with light indicator with the text “ON” or “OFF”.