Possible Duplicate:
Android Button: set onClick background image change with XML?
I need that when you touch the screen changes background.
I have a flashlight.xml, FlashlightActivity and two pictures background1 and bacground2.
I know it’s not so hard to tell me
I tried:
public void onClick(View v) {
if (v==Button1)
Button1.setImageResource(R.drawable.background1);
else if Button1.setImageResource(R.drawable.background2);
}
});
for this you have to create a two layout inside one main linear layout and give layout width and height both fill parent. Make one of the layout invisible by default and make it visible in the layout click of the another layout.
In your activity in your layout click handle like this (not exactly),