简体   繁体   中英

android expandable list view get group from child

I have a button in a child, and I want to change a group's TextView of this child. In my getChildView I got.

    holderChild.revert = (ImageView) convertView.findViewById(R.id.revert);
    holderChild.revert.setOnClickListener(new OnClickListener() {

        public void onClick(View v) 
        {
            ViewHolderChild v2 = (ViewHolderChild)((View)v.getParent()).getTag();

        }
    });

And with this I have the child, but I'd want to have the group of this child

Take a look at this: http://developer.android.com/reference/android/widget/ExpandableListView.OnChildClickListener.html

However, this is a sample code:

// Listview on child click listener
expListView.setOnChildClickListener(new OnChildClickListener() {

@Override
public boolean onChildClick(ExpandableListView parent, View v,
        int groupPosition, int childPosition, long id) {
    // TODO Auto-generated method stub
    Toast.makeText(
            getApplicationContext(),
            listDataHeader.get(groupPosition)
                    + " : "
                    + listDataChild.get(
                            listDataHeader.get(groupPosition)).get(
                            childPosition), Toast.LENGTH_SHORT)
            .show();
    return false;
}
});

I hope its useful for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM