android - with custom Textview: ellipsize="marquee" run as ellipsize="end" -


marquee options working perfect in normal textview i'm in need extend textview class on replace text image inside string. problem when use class marquee option not works, im sure cause dont know ovveride else. please elp subclass:

public class textviewwithimages extends textview {  public textviewwithimages(context context, attributeset attrs, int defstyle) {     super(context, attrs, defstyle); } public textviewwithimages(context context, attributeset attrs) {     super(context, attrs); } public textviewwithimages(context context) {     super(context); } @override public void settext(charsequence text, buffertype type) {     spannable s = gettextwithimages(getcontext(), text);     super.settext(s, buffertype.spannable); }  private static final spannable.factory spannablefactory = spannable.factory.getinstance();  private static boolean addimages(context context, spannable spannable) {     pattern refimg = pattern.compile("\\q[img src=\\e([a-za-z0-9_]+?)\\q/]\\e");     boolean haschanges = false;      matcher matcher = refimg.matcher(spannable);     while (matcher.find()) {         boolean set = true;         (imagespan span : spannable.getspans(matcher.start(), matcher.end(), imagespan.class)) {             if (spannable.getspanstart(span) >= matcher.start()                     && spannable.getspanend(span) <= matcher.end()                     ) {                 spannable.removespan(span);             } else {                 set = false;                 break;             }         }         string resname = spannable.subsequence(matcher.start(1), matcher.end(1)).tostring().trim();         int id = context.getresources().getidentifier(resname, "drawable", context.getpackagename());         if (set) {             haschanges = true;             spannable.setspan(  new imagespan(context, id),                     matcher.start(),                     matcher.end(),                     spannable.span_exclusive_exclusive             );         }     }      return haschanges; } private static spannable gettextwithimages(context context, charsequence text) {     spannable spannable = spannablefactory.newspannable(text);     addimages(context, spannable);     return spannable; }  } 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -