I\'m always using onclick() event in most of my projects. But, I read about OnClickListener(). Can anyone tell what\'s the difference between these
Consider "OnClickListener" as a guy who is waiting your user to click the button of your app. Then your guy will execute your method OnClick().
You have to put an id to your button in your xml file, then give it a name in your MainActivity.java file. Then set a click listener to your guy. And add your onClick method. That's why onClick is bound to the interface View.OnClickListener : https://developer.android.com/reference/android/view/View.OnClickListener.html
Example :
Button myButton = (Button)findViewById(R.id.myButton);
myButton.setOnClickListener(new View.OnClickListener(){
@override
public void onClick(View v) {
// your method...
}
}