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

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -