Ideas:
1. Record Action_down ax, ay coordinates;
2. In the action_move to determine whether to move, move the record time is canceled, no movement on the record;
3. Record the time, press the coordinates, the movement coordinates display in TextView AA, BB, CC respectively;
Statement
1 public class mainactivity extends actionbaractivity { 2 private static TextView AA, BB, CC; 3 private float Atime; 4 private float AX, AY; 5 private boolean mpressbreak = false ;
Specified
1 aa = (TextView) Findviewbyid (r.id.textview1); 2 bb =3 cc = (TextView) Findviewbyid (R.ID.TEXTVIEW3);
Get a long press time
1 @Override2 Public Booleanontouchevent (Motionevent event) {3 //TODO auto-generated Method Stub4 Super. Ontouchevent (event);5String str = "";6 Switch(Event.getaction ()) {7 CaseMotionevent.action_down:8AX =event.getx ();9AY =event.gety ();Tenstr = string.valueof (AX) + "," +string.valueof (AY); One Bb.settext (str); AMpressbreak =false; - Break; - CaseMotionevent.action_move: the -Atime = (Event.geteventtime ()-event.getdowntime ())/1000; -str = string.valueof (Event.getx ()) + "," -+string.valueof (Event.gety ()); + if((Math.Abs (Event.getx ()-AX)) > 10) -|| (Math.Abs (Event.gety ()-AY) > 10)) { +Atime = 0; AMpressbreak =true; at } - Break; - - } - - if(!mpressbreak) { inAa.settext (String.valueof (int) (Atime )); - Cc.settext (str); to } + - return true; the}
Android Motionevent get long press time long