onclicklistener - How do android's Event Listeners work? -


how event captured view object? there 1 thread running : ui thread (when haven't implemented of our own threads). suppose if have implemented onclicklistener button , button's function "cancel". event raised button i.e., cancel whatever ui doing, must interrupt. it? work interrupts?

the api guides @ developer site beautiful explanations still don't give complete picture. http://developer.android.com/guide/topics/ui/ui-events.html

internally, android running event loop handle ui events. nice diagram, see a third slide of presentation. thread being used dispatch system calls ui elements:

the system not create separate thread each instance of component. components run in same process instantiated in ui thread, , system calls each component dispatched thread.

(source: processes , threads)

have @ inside android application framework video google i/o 2008. has nice explanation of event loop (consisting of looper , message queue). interesting stuff starts @ around 26m video.

the onclick() method called same thread original setonclicklistener() called. if main/ui thread, should vary of performing long-running tasks in listener - block ui thread , can cause app non-responsive. use solutions asynctask instead.

please @ this blog post detailed tutorial.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -