title: How to make a custom Gallery view in android
body: <p>I am trying to create a <strong>custom Gallery view</strong>.  Or maybe I'm not understanding what I'm supposed to do here.  I need to overwrite the <strong>onFling()</strong> method of the <strong>Gallery</strong> class, but I do not see how I can do this as my main class must extend from <strong>Activity</strong>.</p>
  
  <p>I have tried making a class called <strong>CustomGallery</strong> that extends <strong>Gallery</strong>, but If I try and run the app I get a force close.</p>
  
  <p>How does one overwrite the <strong>onFling()</strong> method for a Gallery View?</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I am attempting Christian's solution below however, this class has errors all over it.  Clearly I am doing this wrong.  Suggestions?</p>
  
  <pre><code>import android.content.Context;
  import android.util.AttributeSet;
  import android.widget.Gallery;
  
  public class CustomGallery extends Gallery
  {
      public CustomGallery(Context context)
      {
          super(context);
      }
  
      @Override
      public Gallery(Context context)
      {
          this(context, null);
      }
  
      @Override
      public Gallery(Context context, AttributeSet attrs)
      {
          this(context, attrs, R.attr.galleryStyle);
      }
  
      @Override
      public Gallery(Context context, AttributeSet attrs, int defStyle)
      {
          //
      }
  }
  </code></pre>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>ok this got it working, thx Christian!</p>
  
  <pre><code>import android.content.Context;
  import android.util.AttributeSet;
  import android.widget.Gallery;
  
  public class CustomGallery extends Gallery
  {
      public CustomGallery(Context context, AttributeSet attrs)
      {
          super(context, attrs);
  
      }
  
  }
  </code></pre>