How to use getResources() on a Adapter.java
<p>I want to add icons on my TabView, but I am stuck because I can't use <code>getResources()</code> in a custom TabAdapter. I already try to use <code>getAplicationContext().getResources, getActivity.getResources()</code>, but i am still seeing the message <code>"cannot resolve method"</code>. Someone can help me?</p>

<pre><code>   package com.glapps.mobile.codifynotes.Adapter;
   import android.content.Context;
   import android.graphics.drawable.Drawable;
   import android.support.v4.app.Fragment;
   import android.support.v4.app.FragmentManager;
   import android.support.v4.app.FragmentStatePagerAdapter;
   import android.text.Spannable;
   import android.text.SpannableString;
   import android.text.style.ImageSpan;
   import com.glapps.mobile.codifynotes.Activity.MainActivity;
   import com.glapps.mobile.codifynotes.Fragment.CodifyFragment;
   import com.glapps.mobile.codifynotes.Fragment.Configuracoes.ConfiguracoesFragment;

   import com.glapps.mobile.codifynotes.Fragment.DecodifyFragment;
   import com.glapps.mobile.codifynotes.R;
   public class TabAdapter extends FragmentStatePagerAdapter {

private String[] tituloAba = {"CODIFICAR", "DECODIFICAR", "CONFIGURAÇÕES"};
private int[] imageResId = {
        R.drawable.ic_action_lock_closed,
        R.drawable.ic_action_lock_closed,
        R.drawable.ic_action_settings_white
};
public TabAdapter(FragmentManager fm) {
    super(fm);
}

@Override
public Fragment getItem(int position) {
    Fragment fragment = null;

    switch (position){

        case 0:
            fragment = new CodifyFragment();
            break;
        case 1:
            fragment = new DecodifyFragment();
            break;
        case 2:
            fragment = new ConfiguracoesFragment();
    }


    return fragment;
}


@Override
public int getCount() {
    return tituloAba.length;
}

@Override
public CharSequence getPageTitle(int position) {
    return tituloAba[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;
}


   }
</code></pre>

<p><a href="https://i.stack.imgur.com/jwlkk.png" rel="noreferrer">Error image</a></p>

<p>Thank you!</p>