title: Android - Setting custom drawable background to ClickSpan
body: <p>Is there a way we can set a custom drawable (from resources) to a span, especially a ClickSpan, of TextView?</p>
  
  <p>Google returns many answers for disabling highlights or changing colors etc by overriding updateDrawState() of the span, but I do not see how one can set a drawable to the background.</p>
  
  <p>I see a possibility in DynamicDrawableSpan, but I am unable to make it work along with ClickableSpan. This is my code:</p>
  
  <pre><code>public class MyDynamicDrawableSpan extends DynamicDrawableSpan 
  {
      private Context c;
  
  public MyDynamicDrawableSpan(Context context) {
      super();
      c = context;
  }
  
  @Override
  public Drawable getDrawable() {
      Resources res = c.getResources();
      Drawable d = res.getDrawable(R.drawable.span_background);
      return d;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And this is how I use it:</p>
  
  <pre><code>SpannableStringBuilder ssb = new SpannableStringBuilder(text);
  MyDynamicDrawableSpan ddSpan = new MyDynamicDrawableSpan(getApplicationContext());
  ...
  ssb.setSpan(ddSpan, start, end, 0);
  ssb.setSpan(new ClickableSpan(...
  </code></pre>
  
  <p>This does not work. It only helps to make the span invisible. Any bright ideas?</p>