Change the color of a view with a button click in android? -


this create greeting card application , here have change background color of view( background of card) when button clicked. when click button labeled red view should change it's color red. , on. can me this?

 public void myclickhandler(view view) {     switch (view.getid()) {       case r.id.btn1:          layout= (framelayout) findviewbyid(r.id.laidout);         layout.setbackgroundcolor(color.red);         break;          } 

you should write code in onclick(view view) method instead of myclickhandler().and id "btn1" should id name declared in xml file.


Comments

Popular posts from this blog

Glib GIOChannel -

delphi - When I encode/decode SMS PDU (GSM 7 Bit) user data, do I need prepend the UDH first? -

python - Obscure curses error message when creating a sub window -