Views, layouts og fragments Flashcards

Views and layouts (63 cards)

1
Q

What are the interface elements available in Android SDK?

A

Display information, gather information, listen for user actions, style controls, apply themes to the entire screen.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the Android View class?

A

It is a basic user interface building block in the package android.view that represents a rectangular portion of the screen.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a ViewGroup?

A

A ViewGroup contains nested views, such as layouts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the package android.widget contain?

A

It contains mostly visual UI elements (controls) to use on your application screen.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you access a UI element in Java?

A

Use the method findViewById(…) in the Activity class and typecast to the appropriate element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a layout in Android?

A

A layout controls a View object and is a container for other controls (children).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a TextView?

A

A TextView is primarily used to display fixed text strings or labels and inherits attributes from View.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are common TextView attributes?

A

Width, height, padding, and visibility. Recommended to use ‘ems’ for width and ‘lines’ for height.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the autoLink attribute do?

A

It enables linking of text referring to email addresses, web pages, phone numbers, and street addresses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you define an EditText?

A

An EditText is essentially an editable TextView with an android:hint attribute.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are input filters in EditText?

A

Input filters constrain user input, and predefined filters are available in the Android SDK.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is AutoCompleteTextView?

A

It fills in text entries based on user input, showing a developer-provided list that matches.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a Spinner control?

A

A Spinner limits the choices available for users to type and is a list of TextView objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a Toast in Android?

A

A Toast is a view containing a quick message for the user, shown for a short period.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you handle click events?

A

Define a class that implements the interface View.OnClickListener.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is an ImageButton?

A

An ImageButton uses an image instead of text as a label.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is a CheckBox?

A

A CheckBox allows users to select multiple items and shows its state as checked or unchecked.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a ToggleButton?

A

A ToggleButton shows or alters the on or off state of something and has two text fields.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does a Switch control look like?

A

A Switch looks like a slider and can be used to toggle between on and off states.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is a RadioGroup?

A

A RadioGroup allows users to select only one RadioButton from a group.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How do you get dates and times in Android?

A

Use DatePicker and TimePicker classes, implementing their respective change listeners.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is a ProgressBar?

A

A ProgressBar indicates progress when actions take a while, with various styles available.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is a SeekBar?

A

A SeekBar allows users to move an indicator to change the current position in a media file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is a RatingBar?

A

A RatingBar shows or gets a rating from a user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is a Chronometer?
A Chronometer displays time passage.
26
What is a DigitalClock?
A DigitalClock displays time in a digital format.
27
What is an AnalogClock?
An AnalogClock is deprecated in API level 23.
28
What is the purpose of Layout controls in user interfaces?
Layout controls are used to organize screen elements.
29
Where should XML layout files be placed in an Android project?
XML layout files should be placed in the /res/layout directory.
30
What is the default layout file created in new Android projects?
The default layout file is /res/layout/activity_main.xml.
31
How do you associate a layout with an Activity?
Use setContentView(R.layout.activity_main) in the onCreate(...) method.
32
What is the advantage of creating layouts programmatically?
It provides more fine-grained control for dynamic elements.
33
What is a ViewGroup?
A ViewGroup contains other View objects, called child views, and controls a rectangle area of the screen.
34
How can you add Views to a ViewGroup?
You can add Views programmatically using addView() or define them in XML as child nodes.
35
What are ViewGroup subclasses?
ViewGroup subclasses are different classes ending with 'Layout', such as LinearLayout, that act as containers.
36
What is the Layout Inspector Tool?
The Layout Inspector is a tool integrated in Android Studio to inspect View objects and their parent-child relationships.
37
What are some important ViewGroup attributes?
Important attributes include android:layout_height, android:layout_width, and android:layout_margin.
38
What is the purpose of FrameLayout?
FrameLayout displays a stack of child View items, with size determined by the largest View in the stack.
39
What does LinearLayout do?
LinearLayout organizes its child View objects in a single row or column.
40
What is RelativeLayout used for?
RelativeLayout allows specifying the position of child views relative to each other or the parent layout edges.
41
How does TableLayout organize its children?
TableLayout organizes children into rows, using TableRow layout Views for each row.
42
What is GridLayout?
GridLayout organizes its children inside a grid and allows child View controls to span rows and columns.
43
Can multiple layouts be used on a single screen?
Yes, multiple layouts can be combined on a single screen, but complex layouts may cause performance issues.
44
What are Data-Driven Containers?
Data-Driven Containers include ListView, GridView, and GalleryView, allowing users to select items for actions.
45
What is an Adapter in Android?
An Adapter reads data from a data source and provides View objects for child View controls in an AdapterView.
46
What does ArrayAdapter do?
ArrayAdapter binds each element of an array to a single View object within a layout resource.
47
How do you handle selection events in AdapterView?
Use setOnItemClickListener() on the AdapterView to monitor click events.
48
What is ListActivity?
ListActivity simplifies screens that use ListView for full-screen menus or item lists.
49
How can you add scrolling support in Android?
Use ScrollView for vertical scrolling or HorizontalScrollView for horizontal scrolling.
50
What is ViewSwitcher?
ViewSwitcher contains only two child View objects, showing one at a time.
51
What are fragments in Android?
Fragments are modular components that allow for more flexible user interfaces by decoupling the UI from a specific Activity lifecycle.
52
How many fragments can an Activity contain?
One Activity may contain several fragments, allowing for different numbers of fragments to be displayed depending on screen size.
53
What is the purpose of FragmentManager?
FragmentManager facilitates coordination between an Activity and its Fragment components.
54
How do you define a Fragment in XML?
Fragments can be added to layout resource files using the XML tag with the android:name attribute set to the fully qualified Fragment class name.
55
What is a FragmentTransaction?
A FragmentTransaction operation is used to manage fragment modifications, such as attaching, hiding, or adding fragments to the Activity's back stack.
56
What does the onAttach() callback do?
The onAttach() callback is called the first time a Fragment is attached to a specific Activity class.
57
What is a ListFragment?
A ListFragment is a Fragment class that hosts a ListView control, similar to a ListActivity.
58
What is a PreferenceFragment?
A PreferenceFragment is a Fragment class that allows easy management of user preferences, similar to a PreferenceActivity.
59
What is the significance of the android.permission.INTERNET permission?
The android.permission.INTERNET permission is required for an Application to access the internet when using a WebViewFragment.
60
What happens when the screen orientation changes?
Changing the screen orientation triggers onCreate() and can affect the layout and visibility of fragments.
61
What is the purpose of the SimpleFragmentsActivity class?
The SimpleFragmentsActivity class sets up the layout and attaches the toolbar to the activity.
62
What does the VeggieGardenViewActivity class do?
The VeggieGardenViewActivity class manages the display of fragments based on screen orientation and initializes the VeggieGardenWebViewFragment.
63
What is the Android Support Package?
The Android Support Package provides compatibility for fragments introduced in Android 3.0, allowing developers to update legacy applications.