How exactly does int position gets pass into a fragment adapter?

I am very confuse about the following code

   public class SampleFragmentPagerAdapter extends FragmentPagerAdapter {
    final int PAGE_COUNT = 3;
    private String tabTitles[] = new String[] { "Tab1", "Tab2", "Tab3" };

    public SampleFragmentPagerAdapter(FragmentManager fm) {

    public int getCount() {
        return PAGE_COUNT;

    public Fragment getItem(int position) {
        return PageFragment.newInstance(position + 1);

    public CharSequence getPageTitle(int position) {
        // Generate title based on item position
        return tabTitles[position];

My concern is that where does the what passes in the int position argument for the adapter to be able to pass to use it. This concern also extends to the onCreate(Bundle savedInstanceState) code where I am not so sure what exactly pass in the bundle for the activity.


Its called by the FragmentPageAdapter method instantiateItem


Need Your Help

Java Exception Handling custom class

java exception custom-exceptions

I am having trouble handling some exceptions. It would be great if you could point me to a direction so I can understand exceptions better as well as learning to handle exceptions more efficient. T...

USB Communication, Endpoints in Monodroid/Android

java android usb

I have a USB device that I'm attempting to communicate to with my Android 4.1 device using the MonoDroid API, and I've run into some issues setting up a proper connection. First, the steps taken to