• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps programming question

how do i add a click listener to the screen?
to be more spesific i want to know the coordinates where he left the screen (if he moved his finger while touching the screen)
 
implement an OnTouchListener interface, then implement the associated method, like so:
Code:
public void onTouch(MotionEvent e)
{
     if(e.getAction() == MotionEvent.ACTION_UP)
     {
          float x, y;
          x = e.getX();
          y = e.getY();
      }
}
 
How do I refer the screen to a view? so the method will know on what the MotionEvent action was done?

You need to Create an instance of the layour containing the controls and then use the setOnClickListener() method to assign the listener to the layout.
 
Back
Top Bottom