Here is the code
btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) {
where setOnClickListener looks like this:
public void setOnClickListener(android.view.View.OnClickListener l) { }
However, what is the new View.OnClickListener() itself? It turns out this is the interface:
That is, here btn.setOnClickListener(new View.OnClickListener() .... I am creating an instance of the interface. No, this is not an instance of the class that implements this interface.
How to create an instance of the interface?
source share