如何检测在Android触摸输入 [英] How do I detect touch input on the Android
问题描述
现在,所有我试图做的是检测时的画面pssed $ P $,然后显示一个日志信息,以确认它的发生。我的code迄今被修改过的相机preVIEW样品code(最终会拍照),所以的code中的大部分是在扩展SurfaceView类。从SDK的例子code API为7。
Right now all I am trying to do is detect when the screen is pressed and then display a log message to confirm it happened. My code so far is modified off of the CameraPreview sample code (it will eventually take a picture) so the bulk of the code is in a class that extends SurfaceView. API for the example code from the SDK is 7.
推荐答案
尝试下面code来检测触摸事件。
Try code below to detect touch events.
mView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
//show dialog here
return false;
}
});
要显示对话框利用活动的方法的ShowDialog(INT) 。你必须实现onCreateDialog()。有关详细信息,请参阅文档。
To show dialog use Activity method showDialog(int). You have to implement onCreateDialog(). See documentation for details.
这篇关于如何检测在Android触摸输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!