so i have two buttons X and O
every time i click on button X, I want the image to be swapped with O. When I click on the same object again, it should change back to the original image, X...
I've tried several things and the following is what I have but it seems like onClick doesn't do anything in this case...I've done something with a onTouchListener and that works but I couldn't figure out how to revert back to the original.
sorry it looks a little messy, i was just messing with things and commented most of the code out.
Code
public void onClick(View view) {
//final Button xButton = (Button) findViewById(R.id.xButton);
//final Button oButton = (Button) findViewById(R.id.oButton);
if (view.getId() == R.id.xButton) {
view.setBackgroundResource(R.drawable.o_button);
//xButton.setBackgroundResource(R.drawable.o_button);
}
// if (view.getId() == R.id.xButton) {
//
// if (flag) {
// view.setBackgroundResource(R.drawable.o_button);
// oButton.setBackgroundResource(R.drawable.x_button);
// flag = false;
// } else {
// view.setBackgroundResource(R.drawable.x_button);
// oButton.setBackgroundResource(R.drawable.o_button);
// flag = true;
// }
// }
}
This post was edited by iGotThatFiyah on Apr 27 2015 05:23pm