How do I detect touch input on the Android

前端 未结 5 1479
無奈伤痛
無奈伤痛 2020-12-05 11:18

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 CameraPrevi

5条回答
  •  遥遥无期
    2020-12-05 12:01

    Try code below to detect touch events.

    mView.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            //show dialog here
            return false;
        }
    });
    

    To show dialog use Activity method showDialog(int). You have to implement onCreateDialog(). See documentation for details.

提交回复
热议问题