Question Bank and Answer-IV

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

UNIT IV

BUILDING USER INTERFACES

Q1. Explain Text Control


• In android, TextView is a user interface control that is used to
Set and Display the text.
• TextView control will act as like label control and it won’t allow users to edit the text.
• PlainText
• Password
• Password(Number)
• E-Mail
• Phone
• Postal Address
• Multiline Text
• Time
• Date
• Number
• Number (Signed)
• Number (Decimal)
All of above have some same attributes little bit changes in attributes, refer PPT.

Q2. Explain Button Control


• In android, Button is a user interface control that is used to perform an action whenever the user
clicks or tap on it.
• Generally, Buttons in android will contain a text or an icon or both and perform an action when
the user touches it.
• In android, we have a different type of buttons available to use based on our requirements, those
are ImageButton, ToggleButton, RadioButton.

Q3. Explain Toggle Button


• In android, Toggle Button is a user interface control that is used to display ON (Checked)
or OFF (Unchecked) states as a button with a light indicator.
• The ToggleButton is useful for the users to change the settings between two states
either ON or OFF. We can add a ToggleButton to our application layout by using
the ToggleButton object.
• By default, the android ToggleButton will be in OFF (Unchecked) state. We can change the
default state of ToggleButton by using android:checked attribute.
• In case, if we want to change the state of ToggleButton to ON (Checked), then we need to
set android:checked = “true” in our XML layout file.
Q4. Explain Image Button
• In android, Image Button is a user interface control that is used to display a button with an image
and to perform an action when a user clicks or taps on it.
• By default, the ImageButton looks same as normal button and it performs an action when a user
clicks or touches it, but the only difference is we will add a custom image to the button instead of
text.
• In android, we have different types of buttons available to use based on our requirements, those
are Button, ImageButton, ToggleButton, and RadioButton.
• In android, we can add an image to the button by using <ImageButton> attribute android:src in
XML layout file or by using the setImageResource() method.
Q5. Explain Radio Button
• In android, Radio Button is a two-states button that can be either checked or unchecked and it’s
the same as CheckBox control, except that it will allow only one option to select from the group
of options.
• The user can press or click on the radio button to make it select. In android, CheckBox control
allow users to change the state of control either Checked or Unchecked but the radio button
cannot be unchecked once it is checked.
• Generally, we can use RadioButton controls in an android application to allow users to select
only one option from the set of values.

• In android, we use radio buttons with in a RadioGroup to combine multiple radio buttons into
one group and it will make sure that users can select only one option from the group of multiple
options.
• By default, the android RadioButton will be in OFF (Unchecked) state. We can change the
default state of RadioButton by using android:checked attribute.
• In case, if we want to change the state of RadioButton to ON (Checked), then we need to
set android:checked = “true” in our XML layout file.
Q6. Explain RadioGroup Views
In android, Radio Group is used to group one or more radio buttons into separate groups based on our
requirements.

If we group Radio Buttons using RadioGroup, at a time only one item can be selected from the group of radio
buttons. In case, if we select one radio button that belongs to a radio group will unselect all other previously
selected radio buttons within the same group.

Initially, all the radio buttons of the radio group are in the unchecked state, once we select a radio button then
it’s not possible for us to uncheck it like CheckBox control.

Following is the pictorial representation of grouping RadioButton controls using RadioGroup in android
applications.
Android RadioGroup Example
Following is the example of defining multiple RadioButton controls in RadioGroup, one TextView control and
one Button control in RelativeLayout to get the selected values of RadioButton controls when we click
on Button in the android application.

Create a new android application using android studio and give names as RadioButtonExample. In case if you
are not aware of creating an app in android studio check this article Android Hello World App.
Q7. Explain RadioGroup Views

In android, ProgressBar is a user interface control that is used to indicate the progress of an operation. For
example, downloading a file, uploading a file.
Q8. Explain AutoCompleteTextView View
• Android AutoCompleteTextView completes the word based on the reserved words, so no need to
write all the characters of the word.
• Android AutoCompleteTextView is a editable text field, it displays a list of suggestions in a drop
down menu from which user can select only one suggestion or value.
• Android AutoCompleteTextView is the subclass of EditText class. The
MultiAutoCompleteTextView is the subclass of AutoCompleteTextView class.
• Using Array Adapter To Display Text Values In AutoCompleteTextView:
• To display the Array content in an autocompletetextview we need to implement Adapter. In
AutoCompleteTextView we mainly display text values so we use Array Adapter for that.
• ArrayAdapter In Android:
• ArrayAdapter is used when we need list of single type of items which is backed by an Array. For
example, list of phone contacts, countries or names.
• ArrayAdapter code:

Q9 Explain Web view
• Android WebView is used to display web page in android. The web page can be loaded from same
application or URL. It is used to display online content in android activity.
• Android WebView uses webkit engine to display web page.
• The android.webkit.WebView is the subclass of AbsoluteLayout class.
• The loadUrl() and loadData() methods of Android WebView class are used to load and display
web page.

Q10. Explain AnalogClock and DigitalClock Views


• Analog and digital clocks are used for display the time in android application.
1. Analog clock: Analog clock is a subclass of View class. It represents a circular clock. Around the
circle, numbers 1 to 12 appear to represent the hour and two hands are used to show instant of the
time- shorter one for the hour and longer is for minutes.
2. Digital clock: Digital clock is subclass of TextView Class and uses numbers to display the time in
“HH:MM” format.
Q11. Explain TimePicker View, DatePicker View

• Date Picker and Timer Picker Dialog in our android application. These components are used to
select date and time in a customised user interface. We will use DatePickerDialog and
TimePickerDialog classes with Calendar class in our android application code to achieve this.
For code: https://www.journaldev.com/9976/android-date-time-picker-dialog

Q12. Explain Toast Notification


• In android, Toast is a small popup notification that is used to display an information about the
operation which we performed in our app. The Toast will show the message for a small period of
time and it will disappear automatically after a timeout.
• Generally, the size of Toast will be adjusted based on the space required for the message and it will
be displayed on the top of the main content of activity for a short period of time.
• For example, some of the apps will show a message like “Press again to exit” in toast, when we
pressed a back button on the home page or showing a message like “saved successfully” toast when
we click on the button to save the details.

You might also like