title: how to assign counter value to expandable list view button
body: <p>I have expandable list view and each one of view has button. I need to set a tag to each of the button like button1(count 0), button1(count 1), button1(count 2)....... I tried incrementing count each time but it is setting some random counter value. </p>
  
  <p>I am suspecting that I am doing counter++ in wrong place please some one suggest me where I can increment the counter value.</p>
  
  <p><strong>Universally assigning  counter:</strong></p>
  
  <pre><code>int counter = 0;
  </code></pre>
  
  <p><strong>In getChildView() method</strong></p>
  
  <pre><code> @Override
  public View getChildView(final int i, final int i1, boolean b, View view, ViewGroup viewGroup) {
     if (view == null) {
          holder = new ViewHolder();
          LayoutInflater parentInflater = (LayoutInflater) mctx.getSystemService(mctx.LAYOUT_INFLATER_SERVICE);
          view = parentInflater.inflate(R.layout.itemname_child_layout, null);
          holder.button = view.findViewById(R.id.childrecordbtn);
   } else {
          holder = (ViewHolder) view.getTag();
   }
  
   holder.button.setTag(counter);
  
   holder.button..setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            int tag = view.getTag();
            Log.i("Tag Value = ",tag);
          }
   }
   counter++;
   return view;
  }
  </code></pre>
  
  <p>Above code returning some random values after button click.</p>
  
  <p><strong>Output :</strong></p>
  
  <pre><code>Button1 : "Tag Value : 24"
  Button2 : "Tag Value : 25"
  Button3 : "Tag Value : 113"
  </code></pre>