title: How to use getResources() in ViewPager Adapter?
body: <p>I have tried EVERY SINGLE solution available on web and can not get this to work.</p>
  
  <p>Please help me point out my error in this implementation of the <code>ViewPager</code> Adapter, error 'cannot resolve method <code>getResources()</code>' keeps showing up!</p>
  
  <p>Here is my code of the relevant class (problem in the <code>getPageTitle</code> method):</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>public class ViewPagerAdapter extends FragmentStatePagerAdapter {
      CharSequence Titles[]; 
      int NumbOfTabs; 
  
      
      public ViewPagerAdapter(FragmentManager fm,CharSequence mTitles[], int mNumbOfTabsumb) {
          super(fm);
  
          this.Titles = mTitles;
          this.NumbOfTabs = mNumbOfTabsumb;
  
      }
  
  @Override
      public Fragment getItem(int position) {
  
          if(position == 0) 
          {
              Tab1 tab1 = new Tab1();
              return tab1;
          }
          else           
          {
              Tab2 tab2 = new Tab2();
              return tab2;
          }
      }
  
      private int[] imageResId = {
              R.drawable.social,
              R.drawable.artist
      };
  
      @Override
      public CharSequence getPageTitle(int position) {
          // Generate title based on item position
          // return tabTitles[position];
          Drawable image = getResources().getDrawable(imageResId[position]);
          image.setBounds(0, 0, image.getIntrinsicWidth(),                image.getIntrinsicHeight());
          SpannableString sb = new SpannableString(" ");
          ImageSpan imageSpan = new ImageSpan(image, ImageSpan.ALIGN_BOTTOM);
          sb.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
          return sb;
      }
      @Override
      public int getCount() {
          return NumbOfTabs;
      }</code></pre>
  </div>
  </div>
  </p>