android - How to get OnClickListeners out of onCreate? -


how can onclicklisteners out of oncreate? i´m new android programming , have this:

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     startbutton.setonclicklistener(new view.onclicklistener() {           @override         public void onclick(view v) {             pname = edtext.gettext().tostring();             regstat = true;             setcontentview(r.layout.activity_studioreg);         }     }); } 

but how can them in new method , have use them correctly ?

you can use butterknife api, code cleaner like:

@onclick(r.id.start_button) public void onstartbuttontouched() {    // todo } 

http://jakewharton.github.io/butterknife/


Comments