title: Unbolding part of the selected Text not working
body: <p>I am trying to find an answer for unbolding the selected part of the text from other unbolded text but it is unbolding the whole text in the line as shown in the picture. I posted this question a few time but nobody can provide me with the correct answer. I am unbolding the sentence "I am using" but when hit the but it unbolds the whole line. Please help.</p>
  
  <p><a href="https://i.stack.imgur.com/47Up0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/47Up0.png" alt="enter image description here"></a></p>
  
  <p>here is the code I am using.</p>
  
  <pre><code>private void boldText(){
    int selectionStartb = texto.getSelectionStart();
    int selectionEndb = texto.getSelectionEnd();
    if (selectionStartb &gt; selectionEndb) {
        int temp = selectionEndb;
        selectionEndb = selectionStartb;
        selectionStartb = temp;
    }
    if (selectionEndb &gt; selectionStartb) {
        Spannable str = texto.getText();
        boolean BL = false;
        StyleSpan[] styleSpans;
        styleSpans = str.getSpans(selectionStartb, selectionEndb, StyleSpan.class);
        // If the selected text-part already has BOLD style on it, then
        // we need to disable it
        for (int i = 0; i &lt; styleSpans.length; i++) {
            if (styleSpans[i].getStyle() == android.graphics.Typeface.BOLD) {
                str.removeSpan(styleSpans[i]);
                BL = true;
            }
        }
        // Else we set BOLD style on it
        if (!BL) {
            str.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), selectionStartb, selectionEndb,
                    Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        }
  
    }
  </code></pre>
  
  <p>}</p>