How to terminate an Activity in Adroid on touch. Here i shows a view which is described in details.xml. I need to dismiss the activity on touch. I tried the following code. But its not working. Any ideas?
public class Details extends Activity {
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.details);
}
public boolean onTouchEvent(MotionEvent event){
this.finish();
return true;
}
}
You should use
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
finish();
return super.dispatchTouchEvent(ev);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With