title: Get Selected ChipGroup Chip Text Into Clipboard Using Onclick Listener
body: <p>How to get the selected Chip item text from ChipGroup via OnclickListener. Here's what I've done so far. I'm not able toe get the selected item to the ClipBoard:</p>
  
  <pre><code>            for(int i=0; i&lt;tagsJsonArray.length();i++){
                  try {
                      String tag;
                      tag = tagsJsonArray.getString(i);
                      LayoutInflater inflater = LayoutInflater.from(YTTags.this);
                      Chip chip = (Chip) inflater.inflate(R.layout.my_tag,null,false);
                      chip.setText(tag);
                      chip.setClickable(true);
                      chip.setCheckable(true);
                      chipGroup.addView(chip);
                      chip.setOnClickListener(new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
  
                              ClipboardManager copytag = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                              ClipData clip = ClipData.newPlainText("tag", "Hi");
                              copytag.setPrimaryClip(clip);
                              Toast.makeText(YTTags.this, "Copied",Toast.LENGTH_LONG).show();
                          }
                      });
                  }catch (JSONException e){
                      e.printStackTrace();
                  }
              }
  </code></pre>
  
  <p>Onclick listener word fine and copies the dummy text that I've set in the ClipData clip. But I want to access the chip item text.</p>