android - Change Background color on click -


i making simple program in android whenever click on blank screen, screen changes color. can me. how can use onclick function on blank screen.

you can set background so:

layout = (relativelayout) findviewbyid(r.id.layoutname); layout.setbackgroundcolor(androidcolor);// can drawbale file or string colours 

then there few ways click change background. add ontouch listener layout. when true (user presses screen) code gave above called. need edit give don't know naming scheme should job:

layout .setontouchlistener(new view.ontouchlistener() {       @override     public boolean ontouch(view arg0, motionevent arg1) {         layout.setbackgroundcolor(androidcolor);         return true;     } }); 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -