Android: Trying to change color from string
<p>I'm trying to change the string color between these character <code>* *</code>, but something went wrong with my code. The application is finished. 
Every "nota" that contains <code>"*"</code> (i.e. <code>This is * good *</code> ) should change the color of the rest of word "good" and erase <code>"*"</code> characters</p>

<pre><code>if(nota != null){
        if(nota.contains("* *")){

         nota = nota.replace("* *","");

         Spannable spannable = new SpannableString(nota);
         spannable.setSpan(new ForegroundColorSpan(Color.YELLOW), nota.indexOf("* *"), nota.indexOf("* *") + "* *".length(),     Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
         txtnota.setText(spannable);

    }
    }
</code></pre>

<p>UPDATE:</p>

<p>I tried this code, but it is partially coloring the words (not the specific word that I want):</p>

<pre><code>if(nota != null){
        int firstIndex = nota.indexOf("*");
        if (firstIndex &gt;= 0) {
            nota = nota.replaceFirst("[*]{1}", "");
            int secIndex = nota.indexOf("*");
            if (secIndex &gt;= 0) {
                nota = nota.replaceFirst("[*]{1}", "");

                Spannable spannable = new SpannableString("➥ "+nota);
                spannable.setSpan(new ForegroundColorSpan(Color.YELLOW), firstIndex, secIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                spannable.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD_ITALIC), firstIndex, secIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

                txtnota.setText(spannable);
            }
        }
}  
</code></pre>