btn.setTextColor(R.color.main_color);

改为下面方法即可,通过上下文获取颜色值

btn.setTextColor(context.getResources().getColor(R.color.main_color));