title: How to add a touch listener to a surface view?
body: <p>I am new to Android, so please excuse if it is asked before!</p>
  
  <p>I am playing with some camera code (found online) and I want to show/hide some buttons on screen. When the user touches the screen, I want it to capture the image. </p>
  
  <p>My setup:</p>
  
  <p>1.
  Main Activity:</p>
  
  <pre><code>public class CameraDemo extends Activity {
  /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main_inuse);
  
          preview = new Preview(this);
  
          ((FrameLayout) findViewById(R.id.preview)).addView(preview);
  
  ... ...  
  // rest of the code that captures the image when a button is pressed.
  // the button is defined in main.xml with button id ButtonClicked
  }
  </code></pre>
  
  <p>2.
  The preview class looks like this:</p>
  
  <pre><code>class Preview extends SurfaceView implements SurfaceHolder.Callback {
  
      SurfaceHolder mHolder;
      public Camera camera;
  
      Preview(Context context) {
          super(context);
  
          // Install a SurfaceHolder.Callback so we get notified when the
          // underlying surface is created and destroyed.
          mHolder = getHolder();
          mHolder.addCallback(this);
          mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  }
  </code></pre>
  
  <p>My question is,</p>
  
  <ol>
  <li><p>How can I add touch functionality so that the user can touch the preview (say for a second, or just touch quickly) and something happens ? (Say image is saved)</p></li>
  <li><p>And a button will appear on the surface say a "Next" button, for example?</p></li>
  </ol>