* Here we construct one using the position value, but for real application the title should * refer to the item's contents. */ @Override public CharSequence getPageTitle(int position) { return "Item " + (position + 1); } // END_INCLUDE (pageradapter_getpagetitle) /** * Instantiate the {@link View} which should be displayed at {@code position}. Here we * inflate a layout from the apps resources and then change the text view to signify the position. */ @Override public Object instantiateItem(ViewGroup container, int position) { // Inflate a new layout from our resources View view = getActivity().getLayoutInflater().inflate(R.layout.pager_item, container, false); // Add the newly created View to the ViewPager container.addView(view); // Retrieve a TextView from the inflated View, and update it's text TextView title = (TextView) view.findViewById(R.id.item_title); title.setText(String.valueOf(position + 1)); Log.i(LOG_TAG, "instantiateItem() [position: " + position + "]"); // Return the View return view; } /** * Destroy the item from the {@link ViewPager}. In our case this is simply removing the * {@link View}. */ @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); Log.i(LOG_TAG, "destroyItem() [position: " + position + "]"); } } }