title: Why do the list elements not swap?
body: <p>I have a <code>RecyclerView</code> and have implemented an <code>onMove</code> command called <code>onItemMove</code>. I'm using <code>onItemMove</code> to try and get the list elements to swap position when dragged around, but the list elements just hover over each, they don't swap. How can I correct this?</p>
  
  <p>Note 1: <code>onItemDismiss</code> works fine; it swipes the item away and removes it from the list.</p>
  
  <p>Note 2: I've tried to <code>Override</code> <code>onItemMove</code>, but it doesn't actually override its superclass.</p>
  
  <p><strong>List Adaptor Class:</strong> This contains the onItemMove command</p>
  
  <pre><code>public class ListAdapter extends RecyclerView.Adapter&lt;ListAdapter.ListViewHolder&gt; {
      private static final String TAG = "ListAdapter";
      Context context;
      private List&lt;UserData&gt; dataList = new ArrayList&lt;&gt;();
      LayoutInflater inflater;
      Listener listener;
      DbHelper dbHelper;
  
  
  
      public interface Listener {
          void nameToChnge(String name);
      }
  
      public ListAdapter(Context context, List&lt;UserData&gt; dataList1) {
          this.context = context;
          this.dataList = dataList1;
          this.listener= (Listener) context;
          inflater = LayoutInflater.from(context);
      }
  
  
      @Override
      public ListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View convertView = inflater.inflate(R.layout.recylerview_one, parent, false);
          ListViewHolder viewHolder = new ListViewHolder(convertView);
          return viewHolder;
      }
  
      @Override
      public void onBindViewHolder(ListViewHolder holder, final int position) {
          holder.tv_name.setText(dataList.get(position).name);
          holder.tv_quantity.setText(dataList.get(position).quantity);
          holder.tv_description.setText(dataList.get(position).description + "");
  
          holder.relLayout.setOnClickListener(new View.OnClickListener(){
              @Override
              public void onClick(View v) {
                  String s = dataList.get(position).id;
                  Integer stringo = Integer.parseInt(s);
                  Intent intent = new Intent(context, ItemEditActivity.class);
                  intent.putExtra("ItemNumber", stringo);
                  context.startActivity(intent);
              }
          });
      }
  
      @Override
      public int getItemCount() {
          return dataList.size();
      }
  
      class ListViewHolder extends RecyclerView.ViewHolder {
          TextView tv_name, tv_quantity, tv_description;
          RelativeLayout relLayout;
  
  
          public ListViewHolder(View itemView) {
              super(itemView);
              tv_name = (TextView) itemView.findViewById(R.id.nameDisplay);
              tv_quantity = (TextView) itemView.findViewById(R.id.quantityDisplay);
              tv_description = (TextView) itemView.findViewById(R.id.descriptionDisplay);
              relLayout = (RelativeLayout) itemView.findViewById(R.id.relLayout);
          }
      }
  
  
  
      public void onItemDismiss(final int position) {
          dataList.remove(position);
          notifyItemRemoved(position);
  
      }
  
      public void onItemMove(int fromPosition, int toPosition) {
          Collections.swap(dataList, fromPosition, toPosition);
          notifyItemMoved(fromPosition, toPosition);
  
      }
  }
  </code></pre>
  
  <p><strong>ItemTouchHelper Class:</strong> </p>
  
  <pre><code>  public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback{
          private final ListAdapter  mAdapter;
  
  
          public SimpleItemTouchHelperCallback(ListAdapter adapter) {
              mAdapter = adapter;
          }
  
          @Ov
  
  erride
      public boolean isLongPressDragEnabled() {
          return true;
      }
  
      @Override
      public boolean isItemViewSwipeEnabled() {
          return true;
      }
  
      @Override
      public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
          int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
          int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
          return makeMovementFlags(dragFlags, swipeFlags);
      }
  
      @Override
      public boolean onMove(RecyclerView recyclerView,
                            RecyclerView.ViewHolder viewHolder,
                            RecyclerView.ViewHolder target) {
          mAdapter.onItemMove(viewHolder.getAdapterPosition(), target.getAdapterPosition());
  
          return true;
      }
  
      @Override
      public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
          mAdapter.onItemDismiss(viewHolder.getAdapterPosition());
      }
  }
  </code></pre>
  
  <p><strong>Part of the Main Activity where I initialise the <code>RecyclerView</code> and 
  SimpleItemTouchHelperCallback:</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity implements ListAdapter.Listener {
      private static final String TAG = "MainActivity";
  
      RecyclerView recyclerView;
      DbHelper dbHelper;
      ListAdapter adapter;
      FloatingActionButton fab;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          introItem();
          dbHelper = DbHelper.getInstance(getApplicationContext());
  
          recyclerView= (RecyclerView) findViewById(R.id.rv_contactlist);
          adapter = new ListAdapter(this, dbHelper.getAllUser());
          recyclerView.setAdapter(adapter);
          recyclerView.setLayoutManager(new LinearLayoutManager(this));
  
          ItemTouchHelper.Callback callback =
                  new SimpleItemTouchHelperCallback(adapter);
          ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
          touchHelper.attachToRecyclerView(recyclerView);
  
          totalQuantity();
  
          adapter.notifyDataSetChanged();
          fabHideShow();
          versionCheckMethod();
  
      }
  </code></pre>