title: How to Implement Swipe In Android Game Without View
body: <p>I'm trying to make a Snake game on Android in which the snake moves with swipe gestures.</p>
  
  <p>I've tried a lot of ways to get this done but none of them seem to work for me. <strong>I haven't implemented a view - will that be a problem?</strong></p>
  
  <p>This is a sample I tried implementing based on a previous StackOverflow question - <a href="https://stackoverflow.com/questions/4139288/android-how-to-handle-right-to-left-swipe-gestures/19506010#19506010">Android: How to handle right to left swipe gestures</a>.</p>
  
  <p>I created OnSwipeTouchListener.java as instructed. I ran into a bit of a problem with the usage, however.</p>
  
  <p>In GameScreen.java (which is where all the touch events go), I added this as a sample -</p>
  
  <pre><code>onSwipeTouchListener = new OnSwipeTouchListener() {
  public void onSwipeTop() {
      Toast.makeText(MyActivity.this, "top", Toast.LENGTH_SHORT).show();
    }
  public void onSwipeRight() {
      Toast.makeText(MyActivity.this, "right", Toast.LENGTH_SHORT).show();
    }
  public void onSwipeLeft() {
      Toast.makeText(MyActivity.this, "left", Toast.LENGTH_SHORT).show();
    }
  public void onSwipeBottom() {
      Toast.makeText(MyActivity.this, "bottom", Toast.LENGTH_SHORT).show();
    }
  };
  
  imageView.setOnTouchListener(onSwipeTouchListener);
  </code></pre>
  
  <p>This causes a bunch of errors to show up (mainly involving imageView), and none of them could be resolved.</p>
  
  <p>Would anybody happen to have an alternative implementation of swipe specific to my case? </p>