input - Changing background image when tapped -- Android -


I am trying to write a basic app that when the phone taps anywhere, the background image changes If someone can link me in a good tutorial how to do this or some code snippets that I can use it will be appreciated.

Besides, is it possible to put this code in XML or can it be done in Java?

Add an onclick event to the layout and in the listener, change the background

In xml

  & lt; LinearyLayout Android: layout_height = "FILL_PARENT" Android: layout_width = "FILL_PARENT" Android: onClick = "onClick" />   

and in your activity

  click on Public Zero (see V) {v.setBackgroundResource (R.drawable.someDrawable); }    

Comments