I must be overthinking this one, but when I am trying to change the background of a relative layout onClickI am getting the error setBackground in view cannot be set to int.
Here is some of the code below:
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!check) {
check = true;
relativeLayout.setBackground(R.drawable.bg);
^^^Apparently this is considered an int???
} else {
relativeLayout.setBackgroundColor(Color.WHITE);
check = false;
}
}
});
Some things to note:
- The relative layout is attributed to a class that extends a fragment
Btn1andrelativeLayoutwere correctly identified outside of this small section of code. I tried looking around the website for similar problems but could only find one. The solution was to useBitmap Factoryand set theBackgroundtoBitmap bg. This wasn't the solution for me. Also, the background I am trying to reach has been placed in the drawable folder, with an all lowercase name, as a .png. Also, I have build, rebuilt, and cleaned the project--same error. Help?