Is there a way to specify an alternative background image/color for a Button in the XML file that is going to be applied onClick, or do I have to do a But
onClick
But
To change image by using code
public void onClick(View v) { if(v == ButtonName) { ButtonName.setImageResource(R.drawable.ImageName); } }
Or, using an XML file:
In OnClick, just add this code:
OnClick
ButtonName.setBackgroundDrawable(getResources().getDrawable(R.drawable.ImageName));