• 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

Card Range To Study



Play button


Play button




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;

14 Cards in this Set

  • Front
  • Back

What does ViewPager let users do?

swipe across the screen to access different parts of the app

How do you (generally) use ViewPager?

create a new activity where its layout consists of a ViewPager

If your view hierarchy is very simple (just a single View), what can you do?

Don't bother creating an xml file. Instead, create that one view in the java code. however, keep in mind that if it requires a resource, you'll need to create a new xml file called res/values/ids.xml and define the id in it

xml to create a standalone resource id

< item type="id" name="viewPager" />

steps for creating a viewPager in the code instead of xml

- create a resource ID for ViewPager

- create an instance of ViewPager and assign it to mViewPager

- configure it by assigning a resource ID to it

- set your ViewPager as the content view of your activity

syntax to create content view programmatically for ViewPager

mViewPager = new ViewPager(this);



What other things do you need to use with ViewPager?

PagerAdapter and FragmentStatePagerAdapter

FragmentStatePagerAdapter makes the conversation with PagerAdapter simpler

To what methods does FragmentStatePagerAdapter pare down the conversation between ViewPager and PagerAdapter?

getCount() ---> for number of items it can switch between


Syntax for adding PagerAdapter and FragmentStatePagerAdapter

mViewPager.setAdapter(new FragmentStatePagerAdapter(fm) { @Override public Fragment getItem(int position) {

Crime crime = mCrimes.get(position);

return CrimeFragment.newInstance(crime.getmId()); }

@Override public int getCount() {

return mCrimes.size(); }});

What pages does ViewPager load by default?

current page and one to either side for smooth use

How do you change how many pages ViewPager loads?


By default, ViewPager shows the first item in its PagerAdapter. How do you change what it shows? For example, how would you change it so it shows something related to the particular thing you swiped?

in onCreate(){


How do you listen for changes in the page currently being displayed by ViewPager?


FragmentStatePagerAdapter vs FragmentPagerAdapter

With FragmentStatePagerAdapter, your unneeded Fragment is destroyed. In FragmentPagerAdapter, the view is detached but not destroyed, so it remains active in the FragmentManager