Adding Listener on Button Click

2015-10-11 1

Tutorial : Adding a listener on Button Click

Tutor : Inaam Ishaque Shaikh (3rd year Software_University of Sindh Jamshoro)


There are two ways to add Listener on Button

1. Through XML
2. Through implement OnClickListener and Override onClick() method





Way 1:

1. place a button on layout
2. give onClick name
3. call method


way 2:

1. place a button on layout
2. declare and initialize it
3. add onClick listener
4. implement OnClickListener
5. override onClick()