I have a View object in my activity, and I would like to change the background resource of the view. In particular, I would like to switch it.
So, I need this logic:
if (myView.getBackgroundResource() == R.drawable.first) {
myView.setBackgroundResource(R.drawable.second);
}
else {
myView.setBackgroundResource(R.drawable.first);
}
The problem is that there is no getBackgroundResource () method.
How can I get the resource that View uses for its background?
source
share