title: How can I manage order after swiped card back using previous button after swipe again and previous again?
body: <p>Question: How can get all previous swiped cards in stack again if a user click on previous button like <strong>Google primer app</strong>?</p>
  
  <p>Explaination:</p>
  
  <p><strong>Suppose, I have 10 cards. 001, 002...010. Now I started swiping. I swiped 001, 002 and 003, so I'm currently seeing 004. now I clicked on the previous button. So it is showing 003, which is correct.</strong> </p>
  
  <p><strong>After that there are two use case can happen:</strong></p>
  
  <p><strong>1: Suppose I clicked previous button, so it should show 002, which is not showing.</strong></p>
  
  <p><strong>2: Suppose I clicked next button, so it should show 004 again, which is showing also and it is correct, but now again I clicked previous button, now this time it is not showing 003!</strong></p>
  
  <p>Google primer app sample Image: <a href="https://i.stack.imgur.com/BAqCh.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>I tried this library classes in my project because I don't want to add dependency in my project: <a href="https://github.com/flschweiger/SwipeStack" rel="nofollow noreferrer">https://github.com/flschweiger/SwipeStack</a></p>
  
  <p>Swipe Stack Adapter:</p>
  
  <pre><code>public class SwipeStackAdapter extends BaseAdapter {
      public static final String TAG = SwipeStackAdapter.class.getSimpleName();
  
      private List&lt;String&gt; mData;
  
      public SwipeStackAdapter(List&lt;String&gt; data) {
          this.mData = data;
      }
  
      @Override
      public int getCount() {
          return mData.size();
      }
  
      @Override
      public String getItem(int position) {
          return mData.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(final int position, View convertView, ViewGroup parent) {
          convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.card, parent, false);
          TextView textViewCard = convertView.findViewById(R.id.textViewCard);
          textViewCard.setText(mData.get(position));
  
          return convertView;
      }
  
      private void showLog(String msg) {
          Log.d(TAG, msg);
      }
  }
  </code></pre>
  
  <p>I found this method in SwipeStack.java:</p>
  
  <pre><code>private void addNextView() {
      if (mCurrentViewIndex &lt; mAdapter.getCount()) {
          View bottomView = mAdapter.getView(mCurrentViewIndex, null, this);
          bottomView.setTag(R.id.new_view, true);
  
          if (!mDisableHwAcceleration) {
              bottomView.setLayerType(LAYER_TYPE_HARDWARE, null);
          }
  
          if (mViewRotation &gt; 0) {
              bottomView.setRotation(mRandom.nextInt(mViewRotation) - (mViewRotation / 2));
          }
  
          int width = getWidth() - (getPaddingLeft() + getPaddingRight());
          int height = getHeight() - (getPaddingTop() + getPaddingBottom());
  
          LayoutParams params = bottomView.getLayoutParams();
          if (params == null) {
              params = new LayoutParams(
                      FrameLayout.LayoutParams.WRAP_CONTENT,
                      FrameLayout.LayoutParams.WRAP_CONTENT);
          }
  
          int measureSpecWidth = MeasureSpec.AT_MOST;
          int measureSpecHeight = MeasureSpec.AT_MOST;
  
          if (params.width == LayoutParams.MATCH_PARENT) {
              measureSpecWidth = MeasureSpec.EXACTLY;
          }
  
          if (params.height == LayoutParams.MATCH_PARENT) {
              measureSpecHeight = MeasureSpec.EXACTLY;
          }
  
          bottomView.measure(measureSpecWidth | width, measureSpecHeight | height);
          addViewInLayout(bottomView, 0, params, true);
  
          mCurrentViewIndex++;
      }
  }
  </code></pre>
  
  <p>EDIT: Thanks <a href="https://stackoverflow.com/users/4530161/navneet-sharma">Navneet Shamra</a> for your special help. Thanks a lot. I really appreciate your experience and talent.</p>