title: Set and Get item id of recycler view
body: <p>I am new in RecyclerView. We can get clicked item position in RecyclerView, but can we set and get item's ID of RecyclerView? Because in my RecyclerView, the item has custom ID provided by server. I've try this code :</p>
  
  <p><strong>FragmentListProduct.java</strong></p>
  
  <pre><code>productData = new JSONArray();
  linearLayoutManager = new LinearLayoutManager(fragmentActivity);
  lpAdapter = new ListProductAdapter(fragmentActivity, R.layout.list_product_grid, productData, null,
          new ListProductHolder.OnProductClickListener() {
              @Override
              public void onProductClick(View v, long id) {
                  Toast.makeText(fragmentActivity, "id:"+id, Toast.LENGTH_SHORT).show();
                  MainActivity.setIdToRead((int) id);
                  MainActivity.replaceFragment(FragmentListProduct.this, new FragmentViewProduct());
              }
          });
  rvProductList = (RecyclerView) mainView.findViewById(R.id.rvProductList);
  rvProductList.setLayoutManager(linearLayoutManager);
  rvProductList.setAdapter(lpAdapter);
  rvProductList.setHasFixedSize(true);
  </code></pre>
  
  <p><strong>ListProductHolder.java</strong></p>
  
  <pre><code>public class ListProductHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
      TextView tvTitle;
      TextView tvPrice;
      ImageView ivImage;
      private OnProductClickListener onProductClickListener;
  
      ListProductHolder(View itemView, OnProductClickListener onProductClickListener) {
          super(itemView);
          this.onProductClickListener = onProductClickListener;
  
          tvTitle = (TextView) itemView.findViewById(R.id.tvTitle);
          ivImage = (ImageView) itemView.findViewById(R.id.ivImage);
          tvPrice = (TextView) itemView.findViewById(R.id.tvPrice);
          itemView.setOnClickListener(this);
      }
  
      @Override
      public void onClick(View view) {
          onProductClickListener.onProductClick(view, getItemId());
      }
  
      public static interface OnProductClickListener {
          public void onProductClick(View v, long id);
      }
  }
  </code></pre>
  
  <p><strong>ListProdutAdapter.java</strong></p>
  
  <pre><code>public class ListProductAdapter extends RecyclerView.Adapter&lt;ListProductHolder&gt; {
      private Activity activity;
      private int layoutResource;
      private JSONArray productDataArray;
      private StringSignature downloadSignature;
      private ListProductHolder.OnProductClickListener onProductClickListener;
  
      public ListProductAdapter(Activity activity, int layoutResource, JSONArray productDataArray, StringSignature downloadSignature, ListProductHolder.OnProductClickListener onProductClickListener) {
          this.activity = activity;
          this.layoutResource = layoutResource;
          this.productDataArray = productDataArray;
          this.downloadSignature = downloadSignature;
          this.onProductClickListener = onProductClickListener;
      }
  
      @Override
      public ListProductHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View v = LayoutInflater.from(activity).inflate(layoutResource, parent, false);
          return new ListProductHolder(v, onProductClickListener);
      }
  
      @Override
      public void onBindViewHolder(ListProductHolder holder, int position) {...}
  
      @Override
      public long getItemId(int i) {
          long itemId = -1;
          try {
              itemId = productDataArray.getJSONObject(i).getInt("id");
          } catch (JSONException e) {
              e.printStackTrace();
          }
          return itemId;
      }
  }
  </code></pre>
  
  <p>But when i tried it, the ID is always -1. How to solve this? or is there another solution i can do?</p>