Reputation: 165
So I have a code
view.setBackground(ResourcesCompat.getColor(getResources(), R.color.blue, null));
And I have an error
error: incompatible types: int cannot be converted to Drawable
view.setBackground(ResourcesCompat.getColor(getResources(), R.color.blue, null));
So I have another code
view.setBackground(ContextCompat.getColor(MainActivity.this, android.R.color.blue));
And I have another error
error: cannot find symbol
view.setBackground(ContextCompat.getColor(MainActivity.this, android.R.color.blue));
So I have another code
view.setBackground(android.R.color.blue);
and I have another error
error: cannot find symbol
view.setBackground(android.R.color.blue);
Please help. I'm drowning in errors
Upvotes: 1
Views: 1707
Reputation: 187
Try:
view.setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.blue));
Upvotes: 1