There are several common event listeners in the Android system:
1. Click event (View.onclicklistener): This event occurs when the user touches a component or the key is pressed, and the event is handled by the onclick ().
2. Focus event (View.onfocuschangelistener): This event occurs when the component Gets or loses focus, and the event handling method is Onfocuschange ().
3, key event (View.onkey Listener): When the user presses or releases a key on the device, the event handling method is OnKey ().
4, Touch Event (View.ontouchlistener): When the device has a touch screen function, touch the screen to produce the event. The event handling method is Ontouch ().
5. Create context menu event (View.oncreatecontextmenu Listener): This event is generated when the context menu is created, and the event handling method is Oncreatecontextmenu ().
Event Processing steps:
1, create the event supervisor.
2. Register the event supervisor with the component to respond to the event.
3, write the implementation code in the event handling method.
Common events and listeners and their implementation code:
Key Events:
Button.setonclicklistener (New Onclicklistener () {public void OnClick (View arg0) {//...}});
Focus Event:
Text.setonfocuschangelistener (New Onfocuschangelistener () {public void Onfocuschange (View arg0, Boolean arg1) {//. ..... }});
Select event for Multi box :
Checkbox.setoncheckedchangelistener (New Oncheckedchangelistener () {public void oncheckedchanged (Compoundbutton arg0 , Boolean arg1) {//...}});
This article is from the "Useless Uncle" blog, please be sure to keep this source http://aslonely.blog.51cto.com/6552465/1614895
Android Events and event listeners