I’m trying to change the text color in my widget depending on an if. So I have my remoteViews sorted and I can change the actual text with no problem but when I try and change the color using R.color.red it just shows up as black.
RemoteViews remoteViewSmall = new RemoteViews(this.getPackageName(), R.layout.smallwidgetlayout);
remoteViewSmall.setTextColor(R.id.widgetdatasmall, R.color.red);
Is this an incorrect way of retrieving the color “red” I have set in my colors.xml?
You can use the
Color.RED. Would that be what you are looking for?Or are you trying to re-define the colors?
Try this if that is the case:
remoteViewSmall.setTextColor(R.id.widgetdatasmall, getResources().getColor(R.color.red));