btn.setTextColor(R.color.main_color);
改成下面方法便可,經過上下文獲取顏色值ide
btn.setTextColor(context.getResources().getColor(R.color.main_color));