Summary of button event implementation and monitoring methods developed by Android

This paper summarizes the implementation and monitoring method of button event developed by Android. Share with you for your reference, as follows:

First, let's introduce two methods of button event implementation

main.xml

strings.xml

First:

ButtonDemoActivity.java:

Second:

ButtonDemoActivity.java:

Let's talk about the button monitoring method

At present, Android button control mainly has the following listening methods:

A button control corresponds to a listener:

Multiple buttons correspond to one listener 1:

Multiple buttons correspond to one listener 2:

Binding listening in XML:

The corresponding java code is as follows:

Personally, the fourth implementation is not recommended.

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>