I am trying to write a basic app that when the phone is tapped anywhere, the background image changes. If anyone could link me to a good tutorial on how to do this or have some code snippits i could use it would be greatly appreciated.
Also is this possilble to code this in the xml or does it need to be done in java?
Add an onClick event to the layout and in the listener, change the background.
in xml
<LinearyLayout android:layout_height="FILL_PARENT"
android:layout_width="FILL_PARENT"
android:onClick="onClick" />
and in your activity
public void onClick(View v) {
v.setBackgroundResource(R.drawable.someDrawable);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With