Mybotton.java
/*Defining Interfaces*/ Public Interfacemyclick{ Public voidOnmyclick (String str); } /*Initializing interface Variables*/Myclick Myclick=NULL; /*Custom Events*/ Public voidSetonmyclicklistener (Myclick myclick) { This. myclick=Myclick; }
Mainactivity.java
Xxx.setonmyclicklistener (Mybotton. Myclick () { @Override The abstract method in the public void Onmyclick (String str) { //replication interface. Textview1.settext (str); } );
The Setonmyclicklistener () method needs to implement the above interface.
Class Ongesturelistener
Gesturedetector.ontouchevent (event);
Motionevent
Onsingletapup
Onshowpress
Onlongpress
The following two annotated methods are also frequently used
Invalidate (); If you have other needs draw call this method will excite OnDRAW
Postinvalidate (); Use in other non-main threads to prevent ANR
Layoutinflater.from (context). Inflater (R.layout.xxx.xml,this,true);
Custom properties File: Attrs.xml
<?XML version= "1.0" encoding= "Utf-8"?><Resources> <!--Custom Properties - <declare-styleablename= "Header"> <attrname= "Titletextsize"format= "Dimension" /> <attrname= "Titletextcolor"format= "Color" /> <attrname= "TitleText"format= "string"/> </declare-styleable></Resources>
android--Custom events for custom components