About the interpretation and method of setOnClick and other elements in the button click event? And the location and role of toast?

reference links at the end of this article:
tutorials of this code and how to use interfaces, tutorials of switch statements links are links 1.
summary of there are more implementation methods , for link 2.

the links in the text are visually unified, and the links are all at the end of the text. For the convenience of jumping in the text, the jump links in the text are added.

the following code is for me to learn button and simple code related to listeners and click events:

go straight to the code, discussion and consultation tutorials are linked in reference link (if I need to put the tutorial text up):

  five implementations of the Android response onClick method  

Apr.07,2021

1:setOnClickListener is an anonymous inner class

2:Toast is written in the onClick method, onClick is written in the setOnClickListener method, and toast is written in the

in the listener

3: there are many ways to click events. The anonymous inner class is the code in this section, and the interface methods are two commonly used

.

4: maybe setOnClickListener is a callback function, followed by an object instead of a method

still unknown: whether View.OnClickListener is a constructor

Menu