TextViewの一部の色を変える。Spanned spanned = Html.fromHtml
int i;
int staflg = 0;
String str = "";
char chk_char;
String chk_str = "";
String freturn = "<br>";
String redstart = "<font color='#ff0000'><big>";
String redend = "</big></font>";
for(i = 0 ; i < kndsp_note.length(); i++ ){ //レングス取得
chk_char = kndsp_note.charAt(i); //i 文字目取得
chk_str = String.valueOf(chk_char); //char string 変換
if (chk_str.equals("#")){ //string 比較
if (staflg == 0){
str = str + redstart;
staflg = 1;
}else{str = str + redend;
staflg = 0;
}
}else{str = str + chk_str;}
}
// 改行は<br> 赤字は#~~~~~#
TextView textView4=(TextView)this.findViewById(R.id.textView4);
str = str.replace(System.getProperty("line.separator"), "<br />"); //改行コードがきか // なくなるため変換
Spanned spanned = Html.fromHtml(str);
textView4.setText(spanned);
String rrr = "ffffffff";
String freturn = "<br>";
String redstart = "<font color='#ff0000'>";
String fcolorend = "</font>";
TextView textView1=(TextView)this.findViewById(R.id.textView1);
Spanned spanned = Html.fromHtml(
rrr
+ freturn
+ redstart
+rrr
+fcolorend);
textView1.setText(spanned);
TextViewの一部の色を変える。
ffffffff
ffffffff