Search code examples
javaandroidviewexpandablelistviewviewgroup

Is there a way to relate a specific child view with a viewgroup?


What I am trying to do is relate each child view with the viewgroup...in the code to create the child view, a new view group is created with it's elements. Are these automatically associated? I want to be able to change the number in the EditText either by the buttons, or entering the number.

Edit - this is Android/Java.

ExpandableListView


Solution

  • If the view is in a viewgroup, you can use getParent:

    ViewGroup containter = (ViewGroup)myButton.getParent();
    

    I think you want something like:

    ViewGroup group1,group2;
    
    onClick(View v) {
      if (v.getParent() == group1)
        ;
      else if (v.getParent() == group2)
        ;
    }