title: How to implement an endless gallery in Android?
body: <p>I am using a gallery layout in my application. It is working when the user moves the pictures in the gallery from left to right (it is infinite that means elements are repeated again). But when the user moves from right to left and reaches the first element, it doesn't. After then no elements are coming. But I want to repeat elements from this side also. Can you give me some suggestions?</p>
  
  <pre><code> Gallery g = (Gallery) findViewById(R.id.gallery);
          g.setAdapter(new ImageAdapter(this));
          g.setFocusable(true);
          g.setSelection((int)(Integer.MAX_VALUE / 2) - (Integer.MAX_VALUE / 2)% mImageIds.length);        
          g.setOnItemClickListener(new OnItemClickListener() {
              public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) 
              {
                  try {
                      imageid=position;
                      ((ImageView)findViewById(R.id.ImageViewlarge)).setImageResource(mImageIds[position]);
                      ((TextView)findViewById(R.id.TextViewImageName)).setText(imgNames[position]);
                       mp = MediaPlayer.create(SeaSpell.this,audioTrack[position]);
  
                          } catch (Exception e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                              }
  
                  }
              });
  
  
          }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/4DwIV.png" alt="Screenshot Frontgallery"></p>
  
  <p>How can I make my gallery view circular? I am able to do it from left to right infinitely,  but when I drag from right to left it is showing the end point.</p>