Question regarding Tutorial 22 Android Beginner

+1 Joseph Patterson · April 10, 2015
First of all, my experience in programming is pretty limited, so this might be a rather pathetic question. 

During the tutorial, Bucky writes 

    public boolean onTouchEvent(MotionEvent event)
        return super.onTouchEvent(event);

My question is simple: wtf does this do? and what is the point of doing it?

I couldn't understand Bucky's explanation, so it would be best if somebody could give a very clear, step by step explanation on whats going on in this code. 


Post a Reply


Oldest  Newest  Rating
0 Joseph Patterson · May 26, 2015
0 Nicholas Eason · April 13, 2015
From what google is telling me, it basically just lets the device know that it's been touched.

Regarding your other questions:

The point of calling it is when you want to know where the screen has been touched or why it has been touched. As this:

points out, it's used with OpenGL and when you want to get the exact point where it was pressed.

As to the last question, I didn't watch that tutorial you are describing, so I couldn't tell you exactly why he is using onTouchEvent :P
0 Nicholas Eason · April 10, 2015

Means he calls mygestureDetector's onTouchEvent() method

return super.onTouchEvent(event);

Means he returns whatever the super class's onTouchEvent method returns.
0 Joseph Patterson · April 11, 2015
yea i kno that... but what does the touchevent exactly do? what is the point of calling the touchevent? How does the touchevent play in to the program?
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator