title: How to set and get unique name/tag to dynamically added child android
body: <p>I have dynamically added 53 images to <code>ImageView</code> of my layout. I want to set unique id to each image that I added and want to get that id on image click. I have added a tag to my imageview <code>imageView.setTag(WirelessPin.arr_WirelessItems[i]);</code>  but onClick <code>ProductURL = (String) imageView.getTag();</code> always return the tag of last image i.e image no 53. How can I resolve this issue?</p>
  
  <p>Here is my code</p>
  
  <pre><code>for (int i = 0; i &lt; WirelessPin.arr_WirelessItems.length; i++) {
                          url = new URL(WirelessPin.arr_WirelessItems[i].replaceAll("\\s+","%20"));
                          //ProductURL = WirelessPin.arr_WirelessItems[i];
  
                          Bitmap bmp = BitmapFactory.decodeStream(url
                                  .openConnection().getInputStream());
  
                          LinearLayout layout = new LinearLayout(con);
                          layout.setLayoutParams(new LayoutParams(150, 110));
                          layout.setGravity(Gravity.CENTER);
  
                          imageView = new ImageView(con);
                          imageView.setLayoutParams(new LayoutParams(140, 84));
                          imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                          imageView.setImageBitmap(bmp);
  
                          imageView.setTag(WirelessPin.arr_WirelessItems[i]);
  
                          imageView.setOnClickListener(new View.OnClickListener() {
  
                              @Override
                              public void onClick(View v) {
  
                                  //imageView.se
  
                                  ProductURL = (String) imageView.getTag();
                                  CollectDenominationsForWirelessPin obj = new CollectDenominationsForWirelessPin();
                                  obj.WirelessPinDenominations(con, ProductURL, UserId);
  
                              }
                          });
                          layout.addView(imageView);
                          WirelessPin.sliderProducts.addView(layout);
                      }
  </code></pre>