Android setting text view color from java code

前端 未结 9 1339
一个人的身影
一个人的身影 2021-02-07 06:43

I have a list and i write a custom adapter for this. And I want to set some text color for this (e.g. Orange color code #F06D2F). I am presenting the code snippet for my g

9条回答
  •  故里飘歌
    2021-02-07 07:15

    If you want to change your Text Color and take value from values/colors.xml If statement is holding text color for higher api because else version is depreciated in api23

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) 
    {
    textview_name.setTextColor(getColor(R.color.your_color_name));
    }
    else
    {               textview_name.setTextColor(getResources().getColor(R.color.your_color_name));
    }
    

提交回复
热议问题