android - Button.OnClickListener() gives error -
am new in android programming making app in when click button text gonna change... here code..
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button himanshubutton = (button) findviewbyid(r.id.himanshubutton); himanshubutton.setonclicklistener( new button.onclicklistener() { public void onclick(view v){ textview himanshutext = (textview)findviewbyid(r.id.himanshutext); himanshutext.settext("great himanshu rahi");
in button.onclicklistener gives me error red under line..
a better , neat way using method, ask implement setonclicklistener interface once himanshubutton.setonclicklistener(this);
protected void oncreate(bundle savedinstancestate) { button himanshubutton = (button) findviewbyid(r.id.himanshubutton); himanshubutton.setonclicklistener(this); } @override public void onclick(){ textview himanshutext = (textview)findviewbyid(r.id.himanshutext); himanshutext.settext("great himanshu rahi"); }
Comments
Post a Comment