title: Android Expandable List View Get Selected Group Child View
body: <p>I would like to ask how can I get the child view from specific group in expandable list view?</p>
  
  <p><a href="https://i.stack.imgur.com/3BdmE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3BdmE.png" alt="Expandable list view"></a></p>
  
  <p>I have tried with getChildAt(1), but it always return the child view 1(from group view 1) (blue lines and text), when I tried getChildAt(2) it will have error saying pointing view to null reference. How can I make a loop that can detect its group 2 and get its child view? I hope you can understand my question.</p>
  
  <p>For now, I can just only get the group 1 child view with getChildAt(1). I wanted to get the group 2 child view instead. I am going to do a for loop that will loop all the group and update its child view accordingly.</p>
  
  <p>Thanks in advance.</p>
  
  <p>This is my adapter get child view:</p>
  
  <pre><code>    @Override
      public View getChildView(final int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
          LayoutInflater inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView = inflater.inflate(R.layout.personal_loan_list_item, null);
  
      final CustomEditText installmentText = (CustomEditText) convertView.findViewById(R.id.installmentET);
      installmentText.setTag("amount");
  
      installmentText.addTextChangedListener(new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
          }
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
          }
  
          @Override
          public void afterTextChanged(Editable s) {
              try {
                  installmentText.removeTextChangedListener(this);
                  formatText(installmentText, groupPosition);
                  installmentText.addTextChangedListener(this);
              } catch (Exception ex) {
                  ex.printStackTrace();
                  installmentText.addTextChangedListener(this);
              }
          }
      });
  
      return convertView;
  }
  </code></pre>
  
  <p>The formattext method for just formating text during key in session, like 5000 auto change to 5,000 into currency value</p>
  
  <p><a href="https://i.stack.imgur.com/zKmOe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zKmOe.png" alt="enter image description here"></a></p>
  
  <p>In my activity, I used:</p>
  
  <pre><code>listView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
              @Override
              public void onFocusChange(View v, boolean hasFocus) {
                  for(int count = 1; count &lt; people.getLoan().size(); count++) {
                      if(hasFocus) {
                          if (count != lastGroupPos) {
                              View view = listView.getChildAt(1);
                              CustomEditText editTxt = (CustomEditText) view.findViewById(R.id.installmentET);
                              String toSplit = FormatConverterUtil.formatString(editTxt);
                              people.getLoan().get(count - 1).setAmount(toSplit.replace(",", ""));
                          }
                      }
                  }
              }
          });
  </code></pre>