Events for Android custom controls

Source: Internet
Author: User

First, inherit the view that needs to be expanded, and then add one of your own event methods, for example,

Oniconclick (MyInterface pinterface) {

Minterface = Pinterface;

}

Where MyInterface is a custom interface with custom methods such as OnClick, Minterface is an instance of a custom interface that passes the obtained instance to that instance

Next, determine the condition in the event that needs to be extended, such as onkeydown, and call the corresponding method of Minterface

For example, when onkeydown is pressed, the value of key is passed to the MyInterface method, print (String kename)

When using, implement this interface, for example, toast a bit

Another way is to create a new custom method, called in onkeydown, which can be replicated in subclasses of the custom control to achieve a custom implementation of the subclass

When using a custom control, you need the full package name + class name, if inside you need the $ symbol

Events for Android custom controls

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.