android - How to use attributes to change text color from activity -


this code

 textview text_language_name4 = (textview)view.findviewbyid(r.id.text);                      if (text_language_name4 != null) {                          int text_color4 = selected                                  ? getresources().getcolor(r.color.readcolor)                                          : getresources().getcolor(r.color.readcolor);                                                  text_language_name4.settextcolor(text_color4);                          text_language_name4.setduplicateparentstateenabled(true);                   } 

when using r.attr.mytheme app forces close

any suggestions using attr change color of text view

for theme color try this:

typedvalue tv = new typedvalue(); theme theme = context.gettheme(); boolean success = theme.resolveattribute(r.attr.theme_color, tv, true); int colorfromtheme; if(success)     colorfromtheme = tv.data; else     // value not found.... 

now set,

textview.settextcolor(colorfromtheme); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -