正如我在标题中提到的,我不能更改TextView的颜色。(以编程方式)
我试过以下代码,但不起作用:
views.setTextColor( R.id.txtPtw2Gunes, context.getResources().getColor( R.color.widgetOrange ) );
views.setTextColor( R.id.txtPtw2Aksam, Color.parseColor( "#e4e4e4" ) );我能帮你做什么?
编辑: views.setTextColor( R.id.txtPtw2Gunes, context.getResources().getColor( R.color.widgetOrange ) );
实际上,我添加的代码可以工作,但是它不能在模拟器上工作。当我在一个真正的手机上测试它时,我发现它起作用了。
主体可能被锁定。
发布于 2020-12-10 15:39:01
也许你可以尝试这样的方法:
((TextView)findViewById(R.id.txtPtw2Gunes)).setTextColor(getResources().getColor(R.color.widgetOrange));或
((TextView)views.findViewById(R.id.txtPtw2Gunes)).setTextColor(getResources().getColor(R.color.widgetOrange));https://stackoverflow.com/questions/65237156
复制相似问题