Is there a way to set a custom (from resources) resource to a range, especially on ClickSpan, TextView?
Google returns a lot of answers for turning off highlighting or changing colors, etc., overriding the updateDrawState () range, but I donβt see how you can set the highlight for the background.
I see an opportunity in DynamicDrawableSpan, but I can't get it to work with ClickableSpan. This is my 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; }
}
And here is how I use it:
SpannableStringBuilder ssb = new SpannableStringBuilder(text); MyDynamicDrawableSpan ddSpan = new MyDynamicDrawableSpan(getApplicationContext()); ... ssb.setSpan(ddSpan, start, end, 0); ssb.setSpan(new ClickableSpan(...
This does not work. This helps to make an invisible range. Any bright ideas?
Greenbee
source share