How do I apply a style programmatically?

后端 未结 5 694
醉梦人生
醉梦人生 2020-12-08 10:46

I have a styles called Red and Green and I have an if statment to find out which to apply, but I don\'t know the code to actually apply a style from the java.

5条回答
  •  自闭症患者
    2020-12-08 11:39

    It is possible to apply styles programatically to TextViews using setTextAppearance(context, resid) method. (The resId of the style can be found in R.style.YourStyleName)

提交回复
热议问题