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
Post a Comment