1. How the event responds.
Setonclicklistener (view. Onclicklistener l);
Setonfocuschangelistener (View.onfocuschangelistener L)
Setonlongclicklistener (view. Ononclicklistener l);
Setontouchlistener (view. Ontouchlisterner l);
Three ways to respond to events.
The first way:
Final Button Button1 = (Button) Findviewbyid (R.id.button1);
Button1.setonclicklistener (New Onclicklistener () {
public void OnClick (View V) {
Text.set ...;
}
});
The second way:
When defining a class, extend Activity implements Onclicklistener,
Add event Button1.setonclicklistener to the button (this);
Implements the event onclick, public void onclick (View v)
{
Switch (V.getid ()) {
Case
Break
Default
Break
}
}
The third Way: not commonly used.
2. Keyboard response events, i.e. keys
Boolean onKeyDown (int keycode, keyevent msg);
3. Touch Events
Ontouchevent (Motionevent event)
Getaction (); GetX (); GetY () respectively is to get the corresponding action, already coordinates the position.
How to draw:
1. Define a Paint class container, paint class can set the color of paint, Paint.setcolor (color.red); The paint here is the equivalent of a pen, with what color of the pen, what shape of the pen, to paint.
2. Overloaded OnDraw function protect void OnDraw (canvas canvas)//canvas is a canvas
Canvas.drawcircle (X,y,radiu,paint)//indicates, respectively, the horizontal ordinate, radius, and paint brush of the drawing point.
4. Jump and event transfer between screens
Android Development Learning Path-use of basic events