Error in merging spannable objects
<p>I want to merge 3 spannable objects. This code works fine:</p>

<pre><code>Spannable s1 = new SpannableStringBuilder("bold");
             s1.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, s1.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
             Spannable s2 = new SpannableStringBuilder("not");
             Spannable s3 = new SpannableStringBuilder("BOLD");
             s3.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, s3.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
             finishSpan = (Spanned) TextUtils.concat(s1,s2);
             finishSpan = (Spanned) TextUtils.concat(finishSpan,s3);
</code></pre>

<p>//////////////////////////////////////////////////////</p>

<p>or <code>finishSpan = (Spanned) TextUtils.concat(s1,s2,s3);</code></p>

<p>I have the same code but when I merge 3 object,the result is wrong.
I have checked that the type of certain elements are true.<br>
beginningOfModifiedSpannable is bold, selectionSpannable is normal,endOfModifiedSpannable is bold
But their merging is wrong. Only the last part of the result string is bold. Why it happens?? I have the same code above and it works well!</p>

<pre><code>  Spannable str = contentText.getText();
            Spannable selectionSpannable = new SpannableStringBuilder(str, selectionStart, selectionEnd);
            StyleSpan[] ss = selectionSpannable.getSpans(0, selectionSpannable.length(), StyleSpan.class);

            boolean exists = false;
            for (int i = 0; i &lt; ss.length; i++) {
                if (ss[i].getStyle() == android.graphics.Typeface.BOLD){
                 selectionSpannable.removeSpan(ss[i]);
                    exists = true;
                }
            }

            if (!exists){
                str.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), selectionStart, selectionEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
            else {

             Spannable endOfModifiedSpannable = new SpannableStringBuilder(str, selectionEnd, contentText.getText().length());
             Spannable beginningOfModifiedSpannable = new SpannableStringBuilder(str, 0, selectionStart);
             Spanned finishSpan = null;

             if(beginningOfModifiedSpannable.length() &gt; 0) {

              if(endOfModifiedSpannable.length() &gt; 0) {
               finishSpan = (Spanned) TextUtils.concat(beginningOfModifiedSpannable,selectionSpannable);
               finishSpan = (Spanned) TextUtils.concat(finishSpan,endOfModifiedSpannable);
                 }
              else {
               finishSpan = (Spanned) TextUtils.concat(beginningOfModifiedSpannable,selectionSpannable);
              }

             }
             else {
              if(endOfModifiedSpannable.length() &gt; 0) {
               finishSpan = (Spanned) TextUtils.concat(selectionSpannable,endOfModifiedSpannable);
                     }
                  else {
                   finishSpan = selectionSpannable;
                  }
                 }
contentText.setText(finishSpan);
</code></pre>

<p><strong>I repeat that I have checked that 3 parts are true</strong>. E.g. I have 3 parts:
<b>Hel</b> lo,wor  <b>ld</b></p>

<p>I have noticed that the first merging is right:</p>

<pre><code>finishSpan = (Spanned) TextUtils.concat(beginningOfModifiedSpannable,selectionSpannable);
</code></pre>

<p>It looks like <b>Hel</b>lo,wor</p>

<p>But the second is wrong </p>

<pre><code>finishSpan = (Spanned) TextUtils.concat(finishSpan,endOfModifiedSpannable);
</code></pre>

<p>or this merging is wrong:</p>

<pre><code>finishSpan = (Spanned) TextUtils.concat(finishSpan,selectionSpannable,endOfModifiedSpannable);
</code></pre>

<p>And the result of wrong string is:
Hello,wo<b>rld</b></p>

<p>But the true result must be like this:</p>

<p><b>Hel</b>lo,<b>world</b></p>

<p>Nonsense!</p>
