I've been trying to set up buttons and other items with custom colours. I'm new to java, and I've been trying to learn how to use context properly. I have done some research, and I am still unable to find a solution.
The android monitor error is a null pointer exception, and this is the line of code it has a problem with.
int buttonBackground = ContextCompat.getColor(this, R.color.buttonBackgrounds);
I declared this variable within my class, and then further down in a method, I wrote this:
percussionButton.setBackgroundColor(buttonBackground);
instrumentButton.setBackgroundResource(android.R.drawable.btn_default);
I thought that these two might be conflicting, but that's about all I can think off.
I apologise if this has been answered before, I haven't been able to garner an answer from anything I have found so far.
things I've tried before:
int buttonBackground = ContextCompat.getColor(getBaseContext(), R.color.buttonBackgrounds);
int buttonBackground = ContextCompat.getColor(getApplicationContext(), R.color.buttonBackgrounds);