简体   繁体   中英

on touch event in android

i have a screen which is showing some information about version.there is no controll in the screen.i want to finish this activity when i tap on the screen.can anyone help me plz...

Make your activity implement OnTouchListener:

public class MyActivity extends Activity implements OnTouchListener{

// All your code goes here

@Override
    public boolean onTouch(View arg0, MotionEvent arg1) {
        this.finish();
        return false;
    }
}

You could override your activity's onTouchEvent method to finish it:

@Override
public boolean onTouchEvent(MotionEvent event)
{
    this.finish();
    return true;
}

Override onTouchEvent in your activity.

 @Override 
public boolean onTouchEvent (MotionEvent e) {
    this.finish();
    return false;

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM