Android three ways to set click listener

In Android we can set click listener by three ways

  1. Setting individual click listener for each element.
  2. Implementing OnClickListener in activity level.
  3. Creating a separate function for handling button click and add this function in xml

activity_main.xml

In the above example btn_three I have added a property android:onClick=”myBtnClick” myBtnClick is a function I have defined in activiy

MainActivity.java

 

1 Like
Author: bm on July 22, 2016
Category: Android
Tags: , ,

Your comment:

Your Name

Comment:




Last articles