Week 4 - ScrollView, SharedPreferences, Intents, LayoutInflater, AlertDialog, AndroidManifest.xml Flashcards

0
Q

How does one gain access to the shared preferences?

A

This is typically done by requesting the default shared preferences for this activity from the preferences manager. The activity and default shared preferences can be substituted with other things.

Example:

SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);

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

What are Shared Preferences used for?

A

Shared Preferences are used to store simple data in the form of key-value pairs that needs to persist between invocations of an app.

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

How does one add data to, read, and remove data from the shared preferences?

A

After requesting the appropriate shared preferences, data can be added and removed by calling the getXXXXX(), putXXXXX(), and remove() methods of the shared preferences object.

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

What does the layout inflater do?

A

It constructs a concrete GUI that will be presented to the user from an XML layout file.

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

How is the layout inflator used?

A

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View v = inflater.inflate(R.layout.xmlLayoutID, null);

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

How is an alert dialog created and shown?

A

AlertDialog.Builder b = AlertDialog.Builder(this);

b. setTitle(“Foo”);
b. setMessage(“Bar.”);

AlertDialog a = b.create();

a.show();

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

How does one make custom code execute when alert dialog buttons are clicked?

A

By setting a DialogInterface.OnClickListener.

Example:

builder.setPositiveButton("Text",
     New DialogInterface.OnClickListener() {
          // Some action
     }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does a ScrollView do?

A

A ScrollView is a container for views that can be scrolled by the user, allowing them to be larger than the screen. It is a FrameLayout and therefore should only contain one child view.

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

What is the difference between a ScrollView and a ListView?

A

A ScrollView offers more flexibility, whereas a ListView is optimised for scrollable lists.

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

What is the purpose of the Android Manifest XML file?

A

It contains important information about the app, such as:

  • The activities that the app contains.
  • Information about the SDK the app uses, e.g. minimum and target SDK versions.
  • Which types on intents the app can listen for.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly