CH-3
Q. 2 Answer the following questions in short:
1. What is the TextView?
TextView is a user interface element in Android used to display text to the user. It is non-editable and
mainly used to show static text.
2. With the help of example explain RadioButton.
RadioButton allows the user to select one option from a set of choices.
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radio1"
android:text="Option 1" />
<RadioButton
android:id="@+id/radio2"
android:text="Option 2" />
</RadioGroup>
3. What is meant by button? Describe with example.
Button is a clickable UI component used to perform an action when clicked.
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me" />
4. What is the EditText?
EditText is a UI component that allows the user to enter and modify text.
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter your name" />
5. Explain the AutoCompleteTextView in detail.
The AutoCompleteTextView is a type of edit text in android which gives suggestions to the user if the
user types something in the AutoCompleteTextView.
6. Write short note on: ProgressBar.
ProgressBar is a UI element that shows the progress of an operation.
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
7. What is ToggleButton? How to create it? Explain with example.
A ToggleButton is a UI component in Android that allows the user to switch between two states: ON and
OFF. It works like a switch where one state is active at a time.
<ToggleButton
android:id="@+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOn="ON"
android:textOff="OFF" />
textOn → Text displayed when the toggle is ON.
textOff → Text displayed when the toggle is OFF.
8. Describe the following terms:
(i) DatePicker
A DatePicker is a UI component in Android used to select a date (day, month, and year).
It allows users to navigate through a calendar and pick a specific date.
<DatePicker
android:id="@+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
(ii) TimePicker.
A TimePicker is a UI component in Android used to select a specific time (hour and minute).
It can be displayed in either clock mode or spinner mode.
<TimePicker
android:id="@+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Q. 4 Define the terms:
1. Button
A Button is a clickable UI component in Android used to perform an action when clicked.
2. CheckBox
A CheckBox is a UI component used to select one or more options from a set of choices.
3. RadioGroup
A RadioGroup is a container that groups multiple RadioButton components, allowing the user to select
only one option at a time.
4. Toggle Button
A ToggleButton is a button that switches between two states: ON and OFF.
3. What is Scroll View? Explain with example.
A ScrollView is a layout container in Android that allows users to scroll through a large amount of
content that does not fit on the screen. It is a subclass of the ViewGroup class and can contain only one
direct child view.
4.Adapting to display orientation
Adapting to display orientation in Android is crucial for providing a good user experience across different
devices and orientations (portrait and landscape). Android provides several mechanisms to handle
orientation changes effectively.