title: Make selected text from Edittext Bold and not-bold
body: <p>I'm trying to make a feature for my app where the user can make a selected text Bold but I also want to make it so that if the selected text is already bold, then the text shall be set to normal again, a kind of an undo-function.</p>
  
  <p>I have tried over 100 of combinations without any succses! </p>
  
  <pre><code>    CharacterStyle csBold = new StyleSpan(Typeface.BOLD);
      CharacterStyle csNormal = new StyleSpan(Typeface.NORMAL);
      int start = editText.getSelectionStart();
      int end = editText.getSelectionEnd();
      SpannableStringBuilder ssb = new SpannableStringBuilder(editText.getText());
      ssb.setSpan(csBold, start, end, 1);
      SpannableStringBuilder ssb2 = new SpannableStringBuilder(editText.getText());
      ssb2.setSpan(csNormal, start, end, 1);
  
  
  
      switch(item.getItemId()) {
  
          case R.id.bold:
  
              while(editText.isSelected()){
  
              if(editText.getSelectionStart() + editText.getSelectionEnd() == ssb.getSpanStart(start) + ssb.getSpanEnd(end)){
                  editText.setText(ssb2);
                  return true;
  
              }else{
                  editText.setText(ssb);
                  return true;
  
              }
  
              }
  </code></pre>