¡@

Home 

2014/10/16 ¤W¤È 08:10:46

android Programming Glossary: btnlistener

Best practice for defining button events in android

http://stackoverflow.com/questions/6372104/best-practice-for-defining-button-events-in-android

setContentView R.layout.main Button newPicButton Button findViewById R.id.new_button newPicButton.setOnClickListener btnListener ..... similarly for other buttons too ..... Inside of the Button 's onClick event I launch a camera Intent to get a picture.. setContentView R.layout.main Button newPicButton Button findViewById R.id.new_button newPicButton.setOnClickListener btnListener ...similarly for other buttons too I am new to android and this approach of redefining an event every time seems quite dirty.. setContentView R.layout.main Button newPicButton Button findViewById R.id.new_button newPicButton.setOnClickListener btnListener create an anonymous class to act as a button click listener private OnClickListener btnListener new OnClickListener public..