Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
14 Cards in this Set
- Front
- Back
If you need to create a fragment for displaying lists, what parent class should you use for the fragment? |
ListFragment |
|
singleton |
class that only allows one instance of itself to be created. exists as long as the application stays in memory |
|
how do you create a singleton? |
create a class with a private constructor and a get() method that returns the instance (the current one if it exists, or if it doesn't exist it will call the constructor) |
|
Android naming convention for static variables |
sMyVariable |
|
Application context |
context that is global to your application important because you can't be sure other contexts (like activity context) will persist for duration of application |
|
Whenever you have an application-wide singleton, what context should you use? |
application context |
|
Can you populate ListViews with complicated views?
|
yes, or they can just be simple
|
|
Do all items in a ListView exist as inflated Views when the ListView is shown? |
No. Only the ones that are on screen are inflated (as long as you use an adapter) |
|
What does an adapter do? |
Instance of a class that implements the Adapter interface - creates necessary View object - populates it with data from the model layer - return the view to ListView |
|
set up an ArrayAdapter for CrimeListFragment |
ArrayAdapteradapter = new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_1, mCrimes); //this layout is pre-defined by android setListAdapter(adapter); |
|
Regardless of whether the user clicks with a mouse, keyboard, or finger, what convenience method of ListFragment do you override to handle the click event? |
@Override
public void onListItemClick(ListView l, View v, int position, long id) |
|
What ListFragment convenience method do you use to get the adapter set on the ListView? How do you get an item based on its position? |
Crime c = (Crime)(getListAdapter()).getItem(position) //get the position from the click event |
|
When you want to display more than just a string as a ListItem, you need to create a custom list item. What two things do you need for this? |
1. Create a new layout in XML that defines the view for the item 2. Create a new subclass of ArrayAdapter that knows how to create, populate, and return the view defined in the new layout |
|
When using widgets in a custom list item, why should you make things like Buttons and CheckBoxes nonfocusable? |
They're focusable by default and will mess up the onClick method |