タイマー付き単語で段落単語の色を変更する方法第一、第二に、私はの8番目の第2の変化色の後、テキストの第五二変色した後、以下の段落にの色を変更したいようなので、上のとになります... 。TextView:段落内の特定の単語の色を動的に変更する方法
The text will be wrapped in tags, and displayed in a monospaced font.
タイマー付き単語で段落単語の色を変更する方法第一、第二に、私はの8番目の第2の変化色の後、テキストの第五二変色した後、以下の段落にの色を変更したいようなので、上のとになります... 。TextView:段落内の特定の単語の色を動的に変更する方法
The text will be wrapped in tags, and displayed in a monospaced font.
だけTimerを使用して、エディットテキストのフォントの色を変更に応じて、失われた焦点にタイマーを停止。
私はあなたがこのような何かができると思う。
分割法を用いて、言葉に段落:
split(String separator);// it will return an array of Strings
//in your case you will do somthing like this
myWords = paragraph.split(" ");// the separator is the space
そしてを、あなたはあなたがそれらをしたい、これまで何colorateする方法を使用することができます
myNewParagraph.append(HTML.fromHtml("<font color...>... Your HTML Code to colorate your Text"));
、あなたはそれぞれの単語を着色終えたとき、あなたは
01色の新しいテキストを表示するために、あなたのTextViewを更新:メソッドを使用した単語希望します。
テキストの外観を制御するためにスパンを使用できます。 SpannableとCharacterStyleを見てください。
ここは例です。もちろん、これを何らかのタイマーに入れる必要があります。
Spannable spannableText = getSpannableText(yourTextView);
spannableText.setSpan(new TextAppearanceSpan(...), wordStart, wordEnd)
yourTextView.setText(spannableText);
private Spannable getSpannableText(TextView tv) {
CharSequence cs = tv.getText();
if (cs instanceof Spannable) {
return (Spannable)cs;
} else {
return SpannableString.valueOf(cs);
}
}