A figure shows how Android Touch events are transmitted.

Source: Internet
Author: User
Tags gety

A figure shows how Android Touch events are transmitted.

Android programming how to display an image, click the corresponding position of the image and a corresponding event occurs

As follows:
MImage. setOnTouchListener (new OnTouchListener (){
Public boolean onTouch (View v, MotionEvent event ){
If (event. getAction () = MotionEvent. ACTION_DOWN) & (event. getY () <0 )){
////
}
Else if (event. getAction () = MotionEvent. ACTION_DOWN) & (event. getY () <100 )){
////
}
Return false;
}
});
 
Android onTouch event

Yes. set two global variables, for example, global int a and B;
Then in ontouch
Switch (event. getAction ()){
Case MotionEvent. ACTION_DOWN:
A = 1;
Break;
Case MotionEvent. ACTION_MOVE:
B = 2;
Break;
Default:
Break;
}
In this way, when the finger is put down, a = 1, and then B = 2 when the finger is moved;

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.