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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -