I have two types of buttons and I've set a drawable background for each button.
The names of the drawable backgrounds are backgroundblack.xml and backgroundwhite.xml.
When I click on a button how can I know which background is used as drawable background for the clicked button.
Some thing like this:
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myButton.getBackground().getBackgroundName();
}
});
I suppose that this line would give me backgroundblack or backgroundwhite?
This Will Work
myView.getBackgroundDrawable();