android - Layout color should change in respective to alphabets -
hi in project having layout , text view contains 1 alphabet a,b z, want fix ground color of each alphabet. how can ?
you can use switch statement , assign color. if textview name text
string myalphabet=text.gettext().tostring(); switch(myalphabet) { case a: text.settextcolor(color.red); break; case b: text.settextcolor(color.green); break; on ....... } you can set color
text.settextcolor(color.parsecolor("#ffffff")); or
text.settextcolor(color.rgb(200,0,0)); text.settextcolor(color.argb(0,200,0,0)); if want define color in xml then
<color name="errorcolor">#f00</color> and use code show it:
text.settextcolor(getresources().getcolor(r.color.errorcolor));
Comments
Post a Comment