title: How to properly implement onFling method?
body: <p>Okay,In this piece of code I get that your creating instance variables of type gesture detector which will call the FlingGestureListener.class.I'm getting the error <code>a super interface must be an interface</code> but I have created it as of type "interface".The id gives an error also when I refer it to my xml layout name.Implementing FlingGestureListner so my studentGallery class looks like this now and implements the FlingGestureListener:</p>
  
  <pre><code>public class GalleryStudent extends Activity implements FlingGestureLitener {
  
       private static final int MAJOR_MOVE = 0;
  
  
      public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_galery_student);
  
              final GestureDetector gdt = new GestureDetector(getActivity(),
              FlingGestureListener.getInstance(tabSwipeListener));
              final ImageView peopleTab = (ImageView)getActivity().findViewById(R.id.activity_galery_student);
  
              peopleTab.setOnTouchListener(new View.OnTouchListener() {
  
                  @Override
                  public boolean onTouch(View v, MotionEvent event) {
                      return gdt.onTouchEvent(event);
                  }
              });
              Gallery g = (Gallery) findViewById(R.id.gallery);
              g.setAdapter(new ImageAdapter(this));
  
              g.setOnItemClickListener(new OnItemClickListener() {
                  public void onItemClick(@SuppressWarnings("rawtypes") AdapterView parent, View v, int position, long id) {
                      Toast.makeText(GalleryStudent.this, "" + position, Toast.LENGTH_SHORT).show();
                  }
              });
          }
  </code></pre>
  
  <p>I'm confused here as you are using this to naviagate to the class : <code>tabSwipeListener.onTabSwipe(true, PLACES_FRAGMENT);</code> In this case you are taking a fragment as its parameter whereas my classes aren't fragments.Is there a simple way to change my classes to fragments to accommadate this?Also the onTabSwiperListener <code>cannot be resolved to a type</code> in this case.This is the FlingGestureListener I used from your explanation which I have created as an Interface:</p>
  
  <pre><code>public class FlingGestureListener extends SimpleOnGestureListener {
  
  private static final int SWIPE_MIN_DISTANCE = 80;
  private static final int SWIPE_THRESHOLD_VELOCITY = 50;
  private static final int PEOPLE_FRAGMENT = 0;
  private static final int PLACES_FRAGMENT = 2;
  private OnTabSwipedListener tabSwipeListener;
  
  private FlingGestureListener(OnTabSwipedListener tabSwipeListener){
      this.tabSwipeListener = tabSwipeListener;
  
  }
  
  /**
   * Static factory
   * @param listener called when tab swiped
   * @return
   */
  public static FlingGestureListener getInstance(OnTabSwipedListener listener){
      return new FlingGestureListener(listener);
  }
  
  @Override
  public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY){
      if(e1.getX() - e2.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY){
          Log.d("SWIPE", "right to left");
          tabSwipeListener.onTabSwipe(true, PLACES_FRAGMENT); //sent int to fragment container to switch pager to that view 
          return true; //Right to left
      } else if (e2.getX() - e1.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY){
          Log.d("SWIPE", "left to right");
          tabSwipeListener.onTabSwipe(true, PEOPLE_FRAGMENT);
          return true; //Left to right 
      }
  
      //This will test for up and down movement. 
      if(e1.getY() - e2.getY() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY){
          return false; //Bottom to top
      } else if (e2.getY() - e1.getY() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY){
          return false; //Top to bottom 
      }
  
      return false;
      }
  
  }
  </code></pre>
  
  <p>Thanks for the help so far.</p>