Code example for PagerAdapter

0
 
  /* 
   * Inspired by 
   * https://gist.github.com/8cbe094bb7a783e37ad1 
   */ 
  private class SampleAdapter extends PagerAdapter { 
    @Override 
    public Object instantiateItem(ViewGroup container, int position) {
      View page=
          getLayoutInflater().inflate(R.layout.page, container, false);
      TextView tv=(TextView)page.findViewById(R.id.text);
      int blue=position * 25;
 
      tv.setText(String.format(getString(R.string.item), position + 1));
      page.setBackgroundColor(Color.argb(255, 0, 0, blue));
      container.addView(page);
 
      return(page);
    } 
 
    @Override