Android Miscellaneous Pen event handling

Source: Internet
Author: User
Tags event listener

1. Event Listener class: Inner class, external class, Activity, anonymous inner class, directly bound to label

Focus on the use of direct binding to tags

For many of the Android interface component tags, they support onclick,onlongclick attributes such as the method name of a method like XXX (View source), which is a property value. A corresponding method is then defined in the activity of the interface layout, which handles the corresponding event on the control.

Most of the listener classes use anonymous internal classes

2. Callback mechanism

For the event-handling model of the callback, the event source and event listener are unified, or the event listener disappears completely, and when the user fires an event on the GUI component, the component's own specific method is responsible for handling the event, and we cannot add the method dynamically for an object, so we can only inherit the GUI component class. and override the event-handling method of the class to implement the

Callback-based event propagation: Almost all callback-based event-handling methods have a Boolean return value that identifies whether the processing method can handle the event fully, and if the return value is true, indicates that it has been fully processed and, if false, that it is not fully processed. This class of methods that can be propagated out and may call other components

3, Redraw

The OnDraw method of the replication view class can be called automatically by calling the View.invalidate method. OnDraw method

4. Responding to system-set events

Configuration class, the program can get the system configuration object through Getresouces (). GetConfiguration (), once the object is obtained, the object provides some common properties to get the configuration information of the system

Override onconfigurationchanged Response System settings Change

The callback method is called automatically when the system settings change//But, when actually used, this method does not call .... , don't know why

Activity.setrequestorientaiton (acitivityinfo.****); This method can change the direction of the phone settings, but to set up in Mainfest.xml, get permission

Android Miscellaneous Pen event handling

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.