title: Auto show item in recyclerview to another recyclerview?
body: <p>I making an app for tablet so it will have two recyclerview on one activity. What I want to do is when I click an item on first recyclerview, the item information will show automatically on another recyclerview as a list. But what actually my coding do is when I click the item, the item not show automatically on another recyclerview. When I exit the app and relaunch back, finally show the item on another recyclerview.</p>
  
  <p>Actually I have tried put notifysetdatachanged but it still the same.</p>
  
  <p>This MainActivity.java</p>
  
  <pre><code>private void displayItemPurchased() {
      itemList = new ArrayList&lt;&gt;();
  
      Cursor cursorItemPurchased = myDb.getItemPurchased();
      while (cursorItemPurchased.moveToNext()) {
          String itemId = cursorItemPurchased.getString(1);
          String itemDescription = cursorItemPurchased.getString(2);
          int itemQty = cursorItemPurchased.getInt(3);
          Double itemAmt = cursorItemPurchased.getDouble(4);
          String itemTimestamp = cursorItemPurchased.getString(5);
  
          Product_Item item = new Product_Item();
          item.setItemDescription(itemId);
          item.setItemDescription(itemDescription);
          item.setItemQty(itemQty);
          item.setItemAmt(itemAmt);
          item.setItemTimestamp(itemTimestamp);
  
          itemList.add(item);
      }
  
      adapterItemsList = new AdapterItemsList(getApplication(), itemList, cursorItemPurchased);
      rvList.setAdapter(adapterItemsList);
      adapterItemsList.notifyDataSetChanged();
  }
  </code></pre>
  
  <p>This AdapterItem.java</p>
  
  <pre><code>public class AdapterItem extends RecyclerView.Adapter&lt;AdapterItem.MyViewHolder&gt; {
  
      private int row_index = -1;
  
      private ArrayList&lt;Product_Item&gt; itemsList;
      private Context ctx;
      private LayoutInflater inflater;
  
      //SQLite
      DatabaseHelper myDb;
  
      public AdapterItem(Context ctx, ArrayList&lt;Product_Item&gt; itemsList) {
          inflater = LayoutInflater.from(ctx);
          this.ctx = ctx;
          this.itemsList = itemsList;
      }
  
      @NonNull
      @Override
      public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
          View view = inflater.inflate(R.layout.recycler_view_items_list, parent, false);
  
          myDb = new DatabaseHelper(ctx);
  
          return new MyViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) {
  
          Product_Item item = itemsList.get(position);
          final String id = item.getItemId();
          final String name = item.getItemDescription();
          final int qty = Integer.parseInt(holder.txtQty.getText().toString());
          final Double amt = item.getItemAmt();
          final String timestamp =  item.getItemTimestamp();
  
          holder.itemId_tv.setText(id);
          holder.itemName_tv.setText(name);
          holder.btnPlus.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
              }
          });
          holder.btnMinus.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
              }
          });
          holder.itemView.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  row_index = position;
                  notifyDataSetChanged();
                  myDb.insertItemPurchased(id, name, qty, amt, timestamp);
              }
          });
  
          if (row_index == position) {
              holder.layoutQTY.setVisibility(View.VISIBLE);
              holder.layoutQTY.setAnimation(holder.fromBottom);
          } else {
              holder.layoutQTY.setVisibility(View.INVISIBLE);
          }
      }
  
      @Override
      public int getItemCount() {
          return itemsList.size();
      }
  
      public class MyViewHolder extends RecyclerView.ViewHolder {
  
          Animation fromBottom, fromTop;
          LinearLayout layoutQTY;
          TextView itemId_tv, itemName_tv,txtQty;
          ImageButton btnPlus,btnMinus;
  
          MyViewHolder(View itemView) {
              super(itemView);
              fromBottom = AnimationUtils.loadAnimation(ctx,R.anim.qtyfrombottom);
              fromTop = AnimationUtils.loadAnimation(ctx,R.anim.qtyfromtop);
  
              itemId_tv = itemView.findViewById(R.id.txtItemId);
              itemName_tv = itemView.findViewById(R.id.txtName);
              layoutQTY = itemView.findViewById(R.id.layoutQTY);
              txtQty = itemView.findViewById(R.id.txtQty);
              btnPlus = itemView.findViewById(R.id.btnPlus);
              btnMinus = itemView.findViewById(R.id.btnMinus);
          }
      }
  }
  </code></pre>
  
  <p>And This AdapterItemList</p>
  
  <pre><code>public class AdapterItemsList extends RecyclerView.Adapter&lt;AdapterItemsList.ItemListViewHolder&gt; {
  
      private ArrayList&lt;Product_Item&gt; itemsList;
      private Context mContext;
      private Cursor mCursor;
  
      public AdapterItemsList(Context ctx, ArrayList&lt;Product_Item&gt; itemsList, Cursor cursor){
          mContext = ctx;
          this.itemsList = itemsList;
          mCursor = cursor;
      }
  
      public class ItemListViewHolder extends RecyclerView.ViewHolder{
          public TextView nameText;
          public TextView countText;
          public TextView priceText;
  
          public ItemListViewHolder(@NonNull View itemView) {
              super(itemView);
  
              nameText = itemView.findViewById(R.id.txtItemList);
              countText = itemView.findViewById(R.id.txtQty);
              priceText = itemView.findViewById(R.id.txtPriceItem);
  
          }
      }
  
      @NonNull
      @Override
      public ItemListViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
          LayoutInflater inflater = LayoutInflater.from(mContext);
          View view = inflater.inflate(R.layout.recycler_view_pay_list_item,viewGroup,false);
          return new ItemListViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(@NonNull ItemListViewHolder holder, int position) {
          Product_Item item = itemsList.get(position);
          final String id = item.getItemId();
          final String name = item.getItemDescription();
          final int qty = item.getItemQty();
          final Double amt = item.getItemAmt();
          final String timestamp =  item.getItemTimestamp();
  
          holder.nameText.setText(name);
          holder.countText.setText(String.valueOf(qty));
          holder.priceText.setText(String.valueOf(amt));
      }
  
      @Override
      public int getItemCount() {
          return mCursor.getCount();
      }
  
      public void swapCursor (Cursor newCursor){
          if (mCursor != null){
              mCursor.close();
          }
  
          mCursor = newCursor;
  
          if (newCursor != null){
              notifyDataSetChanged();
          }
      }
  </code></pre>