Deck 9: Fragments

Full screen (f)
exit full mode
Question
Fragments were introduced in API level ____________.
Use Space or
up arrow
down arrow
to flip the card.
Question
The Fragment class is final and has no subclass.
Question
The ____________ method is called when a fragment is no longer in use.
Question
The ____________ method is called when a fragment is detached from its activity.
Question
In an app that includes fragments, we cannot have a Model.
Question
What method of the Fragment class returns the Activity that this fragment belongs to?

A) activity
B) fragmentActivity
C) getActivity
D) getFragmentActivity
Question
Fragments cannot exchange data.
Question
We are coding a class encapsulating an invisible fragment. Thus, we do not code the ____________ method.
Question
OnEditorActionListener, a public static inner interface of the TextView class, provides the functionality to handle a(n) ____________ event inside an EditText.
Question
We can obtain a(n) ____________ reference by calling the getSystemService of the Context class.
Question
In order to get a reference to a fragment using its tag name, we call the ____________ method from the FragmentManager class.
Question
It is possible to hide a fragment; that is, the fragment is no longer visible but can be shown later.
Question
It is possible to replace a fragment with another.
Question
One of the add methods of the FragmentTransaction class has this API:
FragmentTransaction add( int containerViewId, Fragment fragment, String s )
What does s represent?

A) A String to be displayed inside the fragment
B) The tag name of the fragment (so we can retrieve it later using that tag name)
C) The title of the fragment
D) The title of the activity
Question
What XML attribute can we use to give Views a size relative to the size of the screen (25%, 50%, etc.)?

A) android:layout
B) android:layout_weight
C) android:weight
D) layout_weight
Question
If we want to close a keyboard associated with an EditText when the user hits the key Done, what value should we assign to the attribute android:imeOptions?

A) done
B) actionDone
C) end
D) close
Question
What method of the Activity class returns the fragment manager for the activity?

A) Manager
B) getManager
C) getFragmentManager
D) fragmentManager
Question
What method of the Fragment class returns the root View for this fragment?

A) view
B) fragmentView
C) getView
D) getFragmentView
Question
It is possible to define a fragment programmatically without using a layout XML file.
Question
If we call the getActivity method inside a user-defined Fragment class and assign the return value to a user-defined Activity class, the Fragment class is not usable with a different user-defined Activity class. To make it reusable with a different user-defined Activity class, we use an interface inside the user-defined Fragment class and have our user-defined Activity class implement that interface.
Question
To get a reference to a fragment using its id, we call the __________________ method from the FragmentManager class.
Question
A fragment can be defined in an XML layout file using a __________________ XML element.
Question
If we intend to call a method of our Activity class with the Activity of a fragment, it is important to __________________ the return object of the getActivity method to that type of Activity.
Question
The __________________ method of the InputMethodManager class can be used to close or hide a keyboard.
Question
The IBinder interface encapsulates a(n) __________________ object.
Question
We can obtain an ____________ reference by calling the getSystemService of the Context class.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/26
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 9: Fragments
1
Fragments were introduced in API level ____________.
eleven
2
The Fragment class is final and has no subclass.
False
3
The ____________ method is called when a fragment is no longer in use.
onDestroy
4
The ____________ method is called when a fragment is detached from its activity.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
5
In an app that includes fragments, we cannot have a Model.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
6
What method of the Fragment class returns the Activity that this fragment belongs to?

A) activity
B) fragmentActivity
C) getActivity
D) getFragmentActivity
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
7
Fragments cannot exchange data.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
8
We are coding a class encapsulating an invisible fragment. Thus, we do not code the ____________ method.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
9
OnEditorActionListener, a public static inner interface of the TextView class, provides the functionality to handle a(n) ____________ event inside an EditText.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
10
We can obtain a(n) ____________ reference by calling the getSystemService of the Context class.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
11
In order to get a reference to a fragment using its tag name, we call the ____________ method from the FragmentManager class.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
12
It is possible to hide a fragment; that is, the fragment is no longer visible but can be shown later.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
13
It is possible to replace a fragment with another.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
14
One of the add methods of the FragmentTransaction class has this API:
FragmentTransaction add( int containerViewId, Fragment fragment, String s )
What does s represent?

A) A String to be displayed inside the fragment
B) The tag name of the fragment (so we can retrieve it later using that tag name)
C) The title of the fragment
D) The title of the activity
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
15
What XML attribute can we use to give Views a size relative to the size of the screen (25%, 50%, etc.)?

A) android:layout
B) android:layout_weight
C) android:weight
D) layout_weight
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
16
If we want to close a keyboard associated with an EditText when the user hits the key Done, what value should we assign to the attribute android:imeOptions?

A) done
B) actionDone
C) end
D) close
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
17
What method of the Activity class returns the fragment manager for the activity?

A) Manager
B) getManager
C) getFragmentManager
D) fragmentManager
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
18
What method of the Fragment class returns the root View for this fragment?

A) view
B) fragmentView
C) getView
D) getFragmentView
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
19
It is possible to define a fragment programmatically without using a layout XML file.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
20
If we call the getActivity method inside a user-defined Fragment class and assign the return value to a user-defined Activity class, the Fragment class is not usable with a different user-defined Activity class. To make it reusable with a different user-defined Activity class, we use an interface inside the user-defined Fragment class and have our user-defined Activity class implement that interface.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
21
To get a reference to a fragment using its id, we call the __________________ method from the FragmentManager class.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
22
A fragment can be defined in an XML layout file using a __________________ XML element.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
23
If we intend to call a method of our Activity class with the Activity of a fragment, it is important to __________________ the return object of the getActivity method to that type of Activity.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
24
The __________________ method of the InputMethodManager class can be used to close or hide a keyboard.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
25
The IBinder interface encapsulates a(n) __________________ object.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
26
We can obtain an ____________ reference by calling the getSystemService of the Context class.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 26 flashcards in this deck.