• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/19

Click to flip

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;

19 Cards in this Set

  • Front
  • Back

options menu

options menu: name of the menu that can appear on the action bar. options typically refer to entire screen or entire app

What's the first step to creating a menu?

they're a resource similar to layouts, so create a res/menu subdirectory and then create a new xml file with an item that has a title, id, showAsAttribute

showAsAttribute

determines whether the menu item appears on the action bar itself or on the overflow menu. don't use always > better to use "ifRoom" and let OS decide

What kinds of items should you put on the action bar?

only ones that users will use frequently --> avoid cluttering the screen

system icon

icon that is found on the device rather than in the project's resources. Fine for prototype but better to have it in your own resources if meant for release --> control what the user sees




(can copy the system icons directly into project's resources)

Two options menu callbacks you'll need in a fragment for implementing an Options menu

public void onCreateOptionsMenu(Menu, MenuInflater)




public boolean onOptionsSelected(MenuItem item)

Code to override onCreateOptionsMenu(...)

@Overridepublic void onCreateOptionsMenu(Menu menu, MenuInflater inflater)


{


super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.fragment_crime_list, menu);


}

What do you do after overriding onCreateOptionsMenu(...)?

Tell the FragmentManager that the fragment should receive a call to onCreateOptionsMenu(...) by adding:


setHasOptionsMenu(true)




in onCreate(...) for the fragment

How do you determine which menu item has been selected?

Check its id




item.getItemId()

temporal navigation

what you get when you use the back button. takes you to where you were last

ancestral navigation

aka hierarchical navigation: takes you up the app hierarchy

Android's recommendation for ancestral navigation

implement the app icon to go "up" one level to the parent of the current activity

How do you visually let the user know the icon is enabled as a "home" button for ancestral navigation?

caret pointing to the left




@TargetApi(11)


if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){ getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);}




//this just enables the caret. it doesn't do the actual wiring

How do you respond to an enabled app icon?

treat as if it were an existing options menu item: override onOptionsItemSelected(MenuItem)

What's the resource id for the android home icon?

android.R.id.home

Best way to implement ancestral navigation

use navUtils and add metadata to the manifest

How do you add parent activity metadata in the manifest?

< meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".CrimeListActivity" />




(basically creating a name-value pair that the NavUtils class can recognize)

After you've added parent activity metadata to the manifest, how do you check whether there's a parent activity and, if so, go back to it?

if (NavUtils.getParentActivityName(getActivity()) != null){ NavUtils.navigateUpFromSameTask(getActivity());}

Why is it better to use NavUtils than starting the parent activity yourself?

short and easy




centralizes relationship between activities in the manifest