title: How to loop through the spans in a SpannedString or SpannableString in Android
body: <p>If I have a <code>SpannedString</code> (or <code>SpannableString</code>) <a href="https://stackoverflow.com/a/41951676/3681880">like this</a></p>
  
  <p><a href="https://i.stack.imgur.com/TDlwU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TDlwU.png" alt="enter image description here"></a></p>
  
  <pre><code>SpannableString spannableString = new SpannableString("Hello World!");
  ForegroundColorSpan foregroundSpan = new ForegroundColorSpan(Color.RED);
  BackgroundColorSpan backgroundSpan = new BackgroundColorSpan(Color.YELLOW);
  spannableString.setSpan(foregroundSpan, 1, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
  spannableString.setSpan(backgroundSpan, 3, spannableString.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
  textView.setText(spannableString);
  </code></pre>
  
  <p>How would I loop through the spans of the resulting <code>String</code>?</p>